instruction stringclasses 100
values | code stringlengths 78 193k | response stringlengths 259 170k | file stringlengths 59 203 |
|---|---|---|---|
Add docstrings for better understanding |
import os
from pathlib import Path
from shutil import rmtree
from beets.dbcore.query import PathQuery
from beets.plugins import BeetsPlugin
from beets.ui import input_options
from beets.util.color import colorize
class ImportSourcePlugin(BeetsPlugin):
def __init__(self):
super().__init__()
self... | --- +++ @@ -1,3 +1,8 @@+"""Adds a `source_path` attribute to imported albums indicating from what path
+the album was imported from. Also suggests removing that source path in case
+you've removed the album from the library.
+
+"""
import os
from pathlib import Path
@@ -10,8 +15,10 @@
class ImportSourcePlugin(B... | https://raw.githubusercontent.com/beetbox/beets/HEAD/beetsplug/importsource.py |
Write documentation strings for class attributes | # This file is part of beets.
# Copyright 2016, Adrian Sampson.
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, ... | --- +++ @@ -12,6 +12,7 @@ # The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
+"""Shows file metadata."""
import os
@@ -92,6 +93,13 @@
def print_data(data, item=None, fmt=None):
+ """Print, with optional formatting, the fields... | https://raw.githubusercontent.com/beetbox/beets/HEAD/beetsplug/info.py |
Generate descriptive docstrings automatically | # This file is part of beets.
# Copyright 2016, Philippe Mongeau.
# Copyright 2025, Sebastian Mohr.
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without ... | --- +++ @@ -31,6 +31,7 @@
def random_func(lib: Library, opts: optparse.Values, args: list[str]):
+ """Select some random items or albums and print the results."""
# Fetch all the objects matching the query into a list.
objs = lib.albums(args) if opts.album else lib.items(args)
@@ -86,6 +87,10 @@ def ... | https://raw.githubusercontent.com/beetbox/beets/HEAD/beetsplug/random.py |
Add docstrings to clarify complex logic | # This file is part of beets.
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribu... | --- +++ @@ -11,6 +11,14 @@ # The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
+"""Adds head/tail functionality to list/ls.
+
+1. Implemented as `lslimit` command with `--head` and `--tail` options. This is
+ the idiomatic way to use th... | https://raw.githubusercontent.com/beetbox/beets/HEAD/beetsplug/limit.py |
Generate docstrings for script automation | # This file is part of beets.
# Copyright 2016, Bruno Cauet
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modi... | --- +++ @@ -12,6 +12,11 @@ # The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
+"""Create freedesktop.org-compliant thumbnails for album folders
+
+This plugin is POSIX-only.
+Spec: standards.freedesktop.org/thumbnail-spec/latest/index.ht... | https://raw.githubusercontent.com/beetbox/beets/HEAD/beetsplug/thumbnails.py |
Document functions with clear intent | #!/usr/bin/env python3
from __future__ import annotations
import re
import subprocess
from collections.abc import Callable
from contextlib import redirect_stdout
from datetime import datetime, timezone
from functools import partial
from io import StringIO
from pathlib import Path
from typing import NamedTuple, TypeA... | --- +++ @@ -1,5 +1,6 @@ #!/usr/bin/env python3
+"""A utility script for automating the beets release process."""
from __future__ import annotations
@@ -34,6 +35,7 @@
class Ref(NamedTuple):
+ """A reference to documentation with ID, path, and optional title."""
id: str
path: str | None
@@ -41,6... | https://raw.githubusercontent.com/beetbox/beets/HEAD/extra/release.py |
Write proper docstrings for these functions |
from __future__ import annotations
from typing import TYPE_CHECKING, Any, ClassVar
from docutils import nodes
from docutils.parsers.rst import directives
from sphinx import addnodes
from sphinx.directives import ObjectDescription
from sphinx.domains import Domain, ObjType
from sphinx.roles import XRefRole
from sphin... | --- +++ @@ -1,3 +1,4 @@+"""Sphinx extension for simple configuration value documentation."""
from __future__ import annotations
@@ -24,12 +25,14 @@
class Conf(ObjectDescription[str]):
+ """Directive for documenting a single configuration value."""
option_spec: ClassVar[OptionSpec] = {
"defau... | https://raw.githubusercontent.com/beetbox/beets/HEAD/docs/extensions/conf.py |
Add docstrings with type hints explained | # This file is part of beets.
# Copyright 2016, Blemjhoo Tezoulbr <baobab@heresiarch.info>.
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitati... | --- +++ @@ -12,6 +12,7 @@ # The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
+"""Moves patterns in path formats (suitable for moving articles)."""
import re
from typing import ClassVar
@@ -65,6 +66,12 @@ self._log.warning... | https://raw.githubusercontent.com/beetbox/beets/HEAD/beetsplug/the.py |
Generate documentation strings for clarity | # This file is part of beets.
# Copyright 2016, Adrian Sampson.
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, ... | --- +++ @@ -12,6 +12,7 @@ # The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
+"""Fetches, embeds, and displays lyrics."""
from __future__ import annotations
@@ -71,8 +72,24 @@
def search_pairs(item):
+ """Yield a pairs of art... | https://raw.githubusercontent.com/beetbox/beets/HEAD/beetsplug/lyrics.py |
Document this script properly | # This file is part of beets.
# Copyright (c) 2011, Jeffrey Aylesworth <mail@jeffrey.red>
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation... | --- +++ @@ -43,6 +43,18 @@
@dataclass
class MusicBrainzUserAPI(MusicBrainzAPI):
+ """MusicBrainz API client with user authentication.
+
+ In order to retrieve private user collections and modify them, we need to
+ authenticate the requests with the user's MusicBrainz credentials.
+
+ See documentation fo... | https://raw.githubusercontent.com/beetbox/beets/HEAD/beetsplug/mbcollection.py |
Add minimal docstrings for each function | # This file is part of beets.
# Copyright 2016, Adrian Sampson and Diego Moreda.
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the righ... | --- +++ @@ -12,6 +12,14 @@ # The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
+"""Aid in submitting information to MusicBrainz.
+
+This plugin allows the user to print track information in a format that is
+parseable by the MusicBrainz t... | https://raw.githubusercontent.com/beetbox/beets/HEAD/beetsplug/mbsubmit.py |
Add return value explanations in docstrings | # This file is part of beets.
# Copyright 2016, Adrian Sampson.
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, ... | --- +++ @@ -12,6 +12,7 @@ # The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
+"""A Web interface to beets."""
import base64
import json
@@ -43,6 +44,10 @@
def _rep(obj, expand=False):
+ """Get a flat -- i.e., JSON-ish -- repre... | https://raw.githubusercontent.com/beetbox/beets/HEAD/beetsplug/web/__init__.py |
Provide docstrings following PEP 257 | # This file is part of beets.
# Copyright 2016, Jakob Schnitzer.
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy,... | --- +++ @@ -12,6 +12,7 @@ # The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
+"""Synchronise library metadata with metadata source backends."""
from collections import defaultdict
@@ -58,6 +59,7 @@ return [cmd]
def fu... | https://raw.githubusercontent.com/beetbox/beets/HEAD/beetsplug/mbsync.py |
Annotate my code with docstrings | # This file is part of beets.
# Copyright 2016, Adrian Sampson.
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, ... | --- +++ @@ -12,6 +12,14 @@ # The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
+"""Updates an MPD index whenever the library is changed.
+
+Put something like the following in your config.yaml to configure:
+ mpd:
+ host: localh... | https://raw.githubusercontent.com/beetbox/beets/HEAD/beetsplug/mpdupdate.py |
Add detailed documentation for each class |
import datetime
import requests
from beets import config, ui
from beets.plugins import BeetsPlugin
from beetsplug.lastimport import process_tracks
from ._utils.musicbrainz import MusicBrainzAPIMixin
class ListenBrainzPlugin(MusicBrainzAPIMixin, BeetsPlugin):
ROOT = "http://api.listenbrainz.org/1/"
def _... | --- +++ @@ -1,3 +1,4 @@+"""Adds Listenbrainz support to Beets."""
import datetime
@@ -11,10 +12,12 @@
class ListenBrainzPlugin(MusicBrainzAPIMixin, BeetsPlugin):
+ """A Beets plugin for interacting with ListenBrainz."""
ROOT = "http://api.listenbrainz.org/1/"
def __init__(self):
+ """In... | https://raw.githubusercontent.com/beetbox/beets/HEAD/beetsplug/listenbrainz.py |
Add docstrings to my Python code | # This file is part of beets.
# Copyright 2023, Daniele Ferone.
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, ... | --- +++ @@ -12,6 +12,10 @@ # The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
+"""The substitute plugin module.
+
+Uses user-specified substitution rules to canonicalize names for path formats.
+"""
import re
@@ -19,8 +23,15 @@
... | https://raw.githubusercontent.com/beetbox/beets/HEAD/beetsplug/substitute.py |
Can you add docstrings to this Python file? | # This file is part of beets.
# Copyright 2016, Blemjhoo Tezoulbr <baobab@heresiarch.info>.
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitati... | --- +++ @@ -12,6 +12,7 @@ # The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
+"""Clears tag fields in media files."""
import re
@@ -86,6 +87,9 @@ return [zero_command]
def _set_pattern(self, field):
+ """Popula... | https://raw.githubusercontent.com/beetbox/beets/HEAD/beetsplug/zero.py |
Add docstrings to improve readability | # This file is part of beets.
# Copyright 2016, Heinz Wiesinger.
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy,... | --- +++ @@ -12,6 +12,7 @@ # The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
+"""Synchronize information from music player libraries"""
from __future__ import annotations
@@ -49,6 +50,9 @@
def load_meta_sources():
+ """Return... | https://raw.githubusercontent.com/beetbox/beets/HEAD/beetsplug/metasync/__init__.py |
Add docstrings to my Python code | # This file is part of beets.
# Copyright 2025, Alexis Sarda-Espinosa.
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use,... | --- +++ @@ -12,6 +12,7 @@ # The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
+"""Adds pseudo-releases from MusicBrainz as candidates during import."""
from __future__ import annotations
@@ -209,6 +210,8 @@ raw_pseudo_release... | https://raw.githubusercontent.com/beetbox/beets/HEAD/beetsplug/mbpseudo.py |
Generate missing documentation strings | # This file is part of beets.
# Copyright 2016, Adrian Sampson.
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, ... | --- +++ @@ -12,6 +12,22 @@ # The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
+"""Updates Subsonic library on Beets import
+Your Beets configuration file should contain
+a "subsonic" section like the following:
+ subsonic:
+ ur... | https://raw.githubusercontent.com/beetbox/beets/HEAD/beetsplug/subsonicupdate.py |
Add docstrings with type hints explained | # This file is part of beets.
# Copyright 2025, Henry Oberholtzer
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy... | --- +++ @@ -12,6 +12,9 @@ # The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
+"""Apply NYT manual of style title case rules, to text.
+Title case logic is derived from the python-titlecase library.
+Provides a template function and a tag... | https://raw.githubusercontent.com/beetbox/beets/HEAD/beetsplug/titlecase.py |
Document this script properly | import json
import random
import re
from urllib.parse import urlparse
import core.config
from core.config import xsschecker
def converter(data, url=False):
if 'str' in str(type(data)):
if url:
dictized = {}
parts = data.split('/')[3:]
for part in parts:
... | --- +++ @@ -85,6 +85,15 @@
def replaceValue(mapping, old, new, strategy=None):
+ """
+ Replace old values with new ones following dict strategy.
+
+ The parameter strategy is None per default for inplace operation.
+ A copy operation is injected via strateg values like copy.copy
+ or copy.deepcopy
+
... | https://raw.githubusercontent.com/s0md3v/XSStrike/HEAD/core/utils.py |
Please document this code using docstrings |
import html
import math
import random
import re
from pathlib import Path
import emoji
import ftfy
from huggingface_hub import hf_hub_download
from unidecode import unidecode
# based on wiki word occurrence
person_token = [("a person", 282265), ("someone", 121194), ("somebody", 12219)]
temp_token = "xtokx" # avoid r... | --- +++ @@ -1,3 +1,6 @@+"""
+Utilities for processing text.
+"""
import html
import math
@@ -33,6 +36,7 @@ self._SPLIT_RE = re.compile("[^a-zA-Z0-9']+")
def __call__(self, s):
+ """Uses dynamic programming to infer the location of spaces in a string without spaces."""
l = [self._split... | https://raw.githubusercontent.com/borisdayma/dalle-mini/HEAD/src/dalle_mini/model/text.py |
Help me write clear docstrings | # coding=utf-8
# Copyright 2022 The Google Research Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicab... | --- +++ @@ -27,6 +27,7 @@ # James Lottes (jlottes at google dot com)
# Anudhyan Boral (anudhyan at google dot com)
#
+"""Distributed Shampoo Implementation."""
import enum
import functools
@@ -61,6 +62,7 @@
# Per parameter optimizer state used in data-parallel training.
class ParameterStats(N... | https://raw.githubusercontent.com/borisdayma/dalle-mini/HEAD/tools/train/scalable_shampoo/distributed_shampoo.py |
Generate consistent documentation across files | #!/usr/bin/env python
# coding=utf-8
# Copyright 2021-2022 The HuggingFace & DALL·E Mini team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.o... | --- +++ @@ -13,6 +13,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+"""
+Training DALL·E Mini.
+Script adapted from run_summarization_flax.py
+"""
import io
import logging
@@ -... | https://raw.githubusercontent.com/borisdayma/dalle-mini/HEAD/tools/train/train.py |
Include argument descriptions in docstrings | # coding=utf-8
# Copyright 2022 The Google Research Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicab... | --- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Helper routines for quantization."""
from typing import Any
@@ -24,6 +25,7 @@ # pylint:disable=no-value-for-parameter
@struct.dataclass
class QuantizedValue:
+ """State assoc... | https://raw.githubusercontent.com/borisdayma/dalle-mini/HEAD/tools/train/scalable_shampoo/quantization_utils.py |
Generate docstrings with parameter types | import random
from dataclasses import dataclass, field
from functools import partial
from pathlib import Path
import jax
import jax.numpy as jnp
import numpy as np
from braceexpand import braceexpand
from datasets import Dataset, load_dataset
from .model.text import TextNormalizer
@dataclass
class Dataset:
data... | --- +++ @@ -305,6 +305,10 @@ dataset: Dataset,
rng: jax.random.PRNGKey = None,
):
+ """
+ Returns batches of size `batch_size` from truncated `dataset`, sharded over all local devices.
+ Shuffle batches if rng is set.
+ """
steps... | https://raw.githubusercontent.com/borisdayma/dalle-mini/HEAD/src/dalle_mini/data.py |
Add docstrings to improve collaboration | # coding=utf-8
# Copyright 2022 The Google Research Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicab... | --- +++ @@ -21,6 +21,7 @@ # Author: Rohan Anil (rohananil at google dot com)
#
+"""SM3 Implementation."""
import functools
from typing import Any, NamedTuple
@@ -40,6 +41,7 @@
# Per parameter optimizer state used in data-parallel training.
class ParameterStats(NamedTuple):
+ """State associated to each par... | https://raw.githubusercontent.com/borisdayma/dalle-mini/HEAD/tools/train/scalable_shampoo/sm3.py |
Write docstrings for data processing functions | # coding=utf-8
# Copyright 2021-2022 The Fairseq Authors and The Google Flax Team Authors And The HuggingFace Inc. team and & DALL·E Mini team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a c... | --- +++ @@ -12,6 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+""" DalleBart model. """
import math
from functools import partial
@@ -53,6 +54,10 @@
def smelu(beta: Any... | https://raw.githubusercontent.com/borisdayma/dalle-mini/HEAD/src/dalle_mini/model/modeling.py |
Help me add docstrings to my project | # coding=utf-8
# Copyright 2022 The Google Research Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicab... | --- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""JAX Ops for symmetric matrices used by the Shampoo optimizer."""
import functools
from typing import Any, List, Optional, Sequence, Union
@@ -26,6 +27,14 @@
@struct.dataclass
cl... | https://raw.githubusercontent.com/borisdayma/dalle-mini/HEAD/tools/train/scalable_shampoo/symmetric_matrices/symmetric_matrices.py |
Improve my code by adding docstrings | #!/usr/bin/env python
# coding=utf-8
# Copyright 2020 The HuggingFace Inc. team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LI... | --- +++ @@ -13,6 +13,11 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+"""
+Fine-tuning the library models for causal language modeling (GPT, GPT-2, CTRL, ...) on a text file or a dat... | https://raw.githubusercontent.com/LlamaFamily/Llama-Chinese/HEAD/train/pretrain/pretrain_clm.py |
Generate docstrings for exported functions | #!/usr/bin/env python
# coding=utf-8
# Copyright 2020 The HuggingFace Inc. team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LI... | --- +++ @@ -13,6 +13,11 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+"""
+Fine-tuning the library models for causal language modeling (GPT, GPT-2, CTRL, ...) on a text file or a dat... | https://raw.githubusercontent.com/LlamaFamily/Llama-Chinese/HEAD/train/sft/finetune_clm_lora.py |
Document this code for team use | #!/usr/bin/env python
# coding=utf-8
# Copyright 2020 The HuggingFace Inc. team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LI... | --- +++ @@ -13,6 +13,11 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+"""
+Fine-tuning the library models for causal language modeling (GPT, GPT-2, CTRL, ...) on a text file or a dat... | https://raw.githubusercontent.com/LlamaFamily/Llama-Chinese/HEAD/train/sft/finetune_clm.py |
Auto-generate documentation strings for this file | from __future__ import print_function, division, absolute_import
from abc import ABCMeta, abstractmethod, abstractproperty
import os
import collections
import six
import numpy as np
import imageio
import imgaug as ia
from .. import dtypes as iadt
from . import meta
from . import size as sizelib
from . import blend ... | --- +++ @@ -1,3 +1,12 @@+"""Augmenters that help with debugging.
+
+List of augmenters:
+
+ * :class:`SaveDebugImageEveryNBatches`
+
+Added in 0.4.0.
+
+"""
from __future__ import print_function, division, absolute_import
from abc import ABCMeta, abstractmethod, abstractproperty
@@ -20,6 +29,15 @@
def _resiz... | https://raw.githubusercontent.com/aleju/imgaug/HEAD/imgaug/augmenters/debug.py |
Improve my code by adding docstrings | from __future__ import print_function, division, absolute_import
import itertools
import numpy as np
import cv2
import six.moves as sm
import imgaug as ia
from . import meta
from .. import parameters as iap
from .. import dtypes as iadt
def convolve(image, kernel):
return convolve_(np.copy(image), kernel)
de... | --- +++ @@ -1,3 +1,17 @@+"""
+Augmenters that are based on applying convolution kernels to images.
+
+List of augmenters:
+
+ * :class:`Convolve`
+ * :class:`Sharpen`
+ * :class:`Emboss`
+ * :class:`EdgeDetect`
+ * :class:`DirectedEdgeDetect`
+
+For MotionBlur, see ``blur.py``.
+
+"""
from __future__ im... | https://raw.githubusercontent.com/aleju/imgaug/HEAD/imgaug/augmenters/convolutional.py |
Insert docstrings into my code | from __future__ import print_function, division, absolute_import
import warnings
import six.moves as sm
import numpy as np
import skimage.filters
import imgaug as ia
from ..imgaug import _numbajit
from .. import dtypes as iadt
from .. import random as iarandom
from .. import parameters as iap
from . import meta
# T... | --- +++ @@ -1,3 +1,72 @@+"""
+Augmenters that wrap methods from ``imagecorruptions`` package.
+
+See `https://github.com/bethgelab/imagecorruptions`_ for the package.
+
+The package is derived from `https://github.com/hendrycks/robustness`_.
+The corresponding `paper <https://arxiv.org/abs/1807.01697>`_ is::
+
+ Hen... | https://raw.githubusercontent.com/aleju/imgaug/HEAD/imgaug/augmenters/imgcorruptlike.py |
Add clean documentation to messy code | from __future__ import print_function, division, absolute_import
import copy as copylib
import numpy as np
import six.moves as sm
import imgaug as ia
# TODO add tests
def copy_augmentables(augmentables):
if ia.is_np_array(augmentables):
return np.copy(augmentables)
result = []
for augmentable in ... | --- +++ @@ -1,3 +1,4 @@+"""Utility functions used in augmentable modules."""
from __future__ import print_function, division, absolute_import
import copy as copylib
import numpy as np
@@ -60,6 +61,19 @@
def normalize_shape(shape):
+ """Normalize a shape ``tuple`` or ``array`` to a shape ``tuple``.
+
+ Para... | https://raw.githubusercontent.com/aleju/imgaug/HEAD/imgaug/augmentables/utils.py |
Write docstrings including parameters and return values | from __future__ import print_function, division, absolute_import
from abc import ABCMeta, abstractmethod
import numpy as np
import cv2
import six
import imgaug as ia
from imgaug.imgaug import _normalize_cv2_input_arr_
from . import meta
from . import blend
from .. import parameters as iap
from .. import dtypes as ia... | --- +++ @@ -1,3 +1,15 @@+"""
+Augmenters that deal with edge detection.
+
+List of augmenters:
+
+ * :class:`Canny`
+
+:class:`~imgaug.augmenters.convolutional.EdgeDetect` and
+:class:`~imgaug.augmenters.convolutional.DirectedEdgeDetect` are currently
+still in ``convolutional.py``.
+
+"""
from __future__ import pr... | https://raw.githubusercontent.com/aleju/imgaug/HEAD/imgaug/augmenters/edges.py |
Add docstrings to improve code quality | from __future__ import print_function, division, absolute_import
import six.moves as sm
import numpy as np
import cv2
import PIL.Image
import PIL.ImageOps
import PIL.ImageEnhance
import PIL.ImageFilter
import imgaug as ia
from imgaug.imgaug import _normalize_cv2_input_arr_
from . import meta
from . import arithmetic
... | --- +++ @@ -1,3 +1,52 @@+"""
+Augmenters that have identical outputs to well-known PIL functions.
+
+The ``like`` in ``pillike`` indicates that the augmenters in this module
+have identical outputs and mostly identical inputs to corresponding PIL
+functions, but do not *have to* wrap these functions internally. They ma... | https://raw.githubusercontent.com/aleju/imgaug/HEAD/imgaug/augmenters/pillike.py |
Create docstrings for API functions | from __future__ import print_function, division, absolute_import
import numpy as np
import cv2
import six.moves as sm
from imgaug.imgaug import _normalize_cv2_input_arr_
from . import meta
from .. import parameters as iap
from .. import dtypes as iadt
# pylint:disable=pointless-string-statement
"""
Speed comparison... | --- +++ @@ -1,3 +1,12 @@+"""
+Augmenters that apply mirroring/flipping operations to images.
+
+List of augmenters:
+
+ * :class:`Fliplr`
+ * :class:`Flipud`
+
+"""
from __future__ import print_function, division, absolute_import
import numpy as np
@@ -671,6 +680,44 @@
def fliplr(arr):
+ """Flip an ima... | https://raw.githubusercontent.com/aleju/imgaug/HEAD/imgaug/augmenters/flip.py |
Document helper functions with docstrings | from __future__ import print_function, division, absolute_import
from abc import ABCMeta, abstractmethod
import numpy as np
import six
import cv2
import imgaug as ia
from imgaug.imgaug import _normalize_cv2_input_arr_
from . import meta
from .. import parameters as iap
from .. import dtypes as iadt
from .. import ra... | --- +++ @@ -1,3 +1,22 @@+"""
+Augmenters that blend two images with each other.
+
+List of augmenters:
+
+ * :class:`BlendAlpha`
+ * :class:`BlendAlphaMask`
+ * :class:`BlendAlphaElementwise`
+ * :class:`BlendAlphaSimplexNoise`
+ * :class:`BlendAlphaFrequencyNoise`
+ * :class:`BlendAlphaSomeColors`
+ ... | https://raw.githubusercontent.com/aleju/imgaug/HEAD/imgaug/augmenters/blend.py |
Add docstrings to existing functions | from __future__ import print_function, division, absolute_import
import numpy as np
from scipy import ndimage
import cv2
import six.moves as sm
import imgaug as ia
from imgaug.imgaug import _normalize_cv2_input_arr_
from . import meta
from . import convolutional as iaa_convolutional
from .. import parameters as iap
f... | --- +++ @@ -1,3 +1,16 @@+"""
+Augmenters that blur images.
+
+List of augmenters:
+
+ * :class:`GaussianBlur`
+ * :class:`AverageBlur`
+ * :class:`MedianBlur`
+ * :class:`BilateralBlur`
+ * :class:`MotionBlur`
+ * :class:`MeanShiftBlur`
+
+"""
from __future__ import print_function, division, absolute... | https://raw.githubusercontent.com/aleju/imgaug/HEAD/imgaug/augmenters/blur.py |
Write Python docstrings for this snippet | from __future__ import print_function, division, absolute_import
import imgaug as ia
class SuspiciousMultiImageShapeWarning(UserWarning):
class SuspiciousSingleImageShapeWarning(UserWarning):
def _warn_on_suspicious_multi_image_shapes(images):
if images is None:
return
# check if it looks like (H... | --- +++ @@ -1,11 +1,21 @@+"""Base classes and functions used by all/most augmenters.
+
+This module is planned to contain :class:`imgaug.augmenters.meta.Augmenter`
+in the future.
+
+Added in 0.4.0.
+
+"""
from __future__ import print_function, division, absolute_import
import imgaug as ia
class SuspiciousMultiI... | https://raw.githubusercontent.com/aleju/imgaug/HEAD/imgaug/augmenters/base.py |
Create docstrings for all classes and functions | from __future__ import print_function, division, absolute_import
import traceback
import collections
import numpy as np
import scipy.spatial.distance
import six.moves as sm
import skimage.draw
import skimage.measure
from .. import imgaug as ia
from .. import random as iarandom
from .base import IAugmentable
from .ut... | --- +++ @@ -1,3 +1,4 @@+"""Classes dealing with polygons."""
from __future__ import print_function, division, absolute_import
import traceback
@@ -23,6 +24,31 @@
def recover_psois_(psois, psois_orig, recoverer, random_state):
+ """Apply a polygon recoverer to input polygons in-place.
+
+ Parameters
+ -... | https://raw.githubusercontent.com/aleju/imgaug/HEAD/imgaug/augmentables/polys.py |
Help me write clear docstrings |
from __future__ import print_function, division, absolute_import
import numpy as np
import cv2
from imgaug.imgaug import _normalize_cv2_input_arr_
from . import meta
from . import color as colorlib
from .. import dtypes as iadt
from .. import parameters as iap
def stylize_cartoon(image, blur_ksize=3, segmentation_... | --- +++ @@ -1,3 +1,13 @@+"""
+Augmenters that apply artistic image filters.
+
+List of augmenters:
+
+ * :class:`Cartoon`
+
+Added in 0.4.0.
+
+"""
from __future__ import print_function, division, absolute_import
@@ -15,6 +25,77 @@ saturation=2.0, edge_prevalence=1.0,
su... | https://raw.githubusercontent.com/aleju/imgaug/HEAD/imgaug/augmenters/artistic.py |
Write proper docstrings for these functions | from __future__ import print_function, division, absolute_import
from abc import ABCMeta, abstractmethod
import numpy as np
import cv2
import six
import six.moves as sm
import imgaug as ia
from imgaug.imgaug import _normalize_cv2_input_arr_
from . import meta
from . import blend
from . import arithmetic
from .. impo... | --- +++ @@ -1,3 +1,30 @@+"""
+Augmenters that affect image colors or image colorspaces.
+
+List of augmenters:
+
+ * :class:`InColorspace` (deprecated)
+ * :class:`WithColorspace`
+ * :class:`WithBrightnessChannels`
+ * :class:`MultiplyAndAddToBrightness`
+ * :class:`MultiplyBrightness`
+ * :class:`Ad... | https://raw.githubusercontent.com/aleju/imgaug/HEAD/imgaug/augmenters/color.py |
Expand my code with proper documentation strings | from __future__ import print_function, division, absolute_import
import numpy as np
from .. import parameters as iap
from .. import random as iarandom
from . import meta
from . import arithmetic
from . import flip
from . import pillike
from . import size as sizelib
class RandAugment(meta.Sequential):
_M_MAX = ... | --- +++ @@ -1,3 +1,12 @@+"""Augmenters that are collections of other augmenters.
+
+List of augmenters:
+
+ * :class:`RandAugment`
+
+Added in 0.4.0.
+
+"""
from __future__ import print_function, division, absolute_import
import numpy as np
@@ -12,6 +21,162 @@
class RandAugment(meta.Sequential):
+ """Appl... | https://raw.githubusercontent.com/aleju/imgaug/HEAD/imgaug/augmenters/collections.py |
Write docstrings for data processing functions | from __future__ import print_function, division, absolute_import
import numpy as np
import six.moves as sm
from .. import imgaug as ia
from ..augmenters import blend as blendlib
from .base import IAugmentable
@ia.deprecated(alt_func="SegmentationMapsOnImage",
comment="(Note the plural 'Maps' instead ... | --- +++ @@ -1,3 +1,8 @@+"""Classes dealing with segmentation maps.
+
+E.g. masks, semantic or instance segmentation maps.
+
+"""
from __future__ import print_function, division, absolute_import
import numpy as np
@@ -11,11 +16,41 @@ @ia.deprecated(alt_func="SegmentationMapsOnImage",
comment="(Note t... | https://raw.githubusercontent.com/aleju/imgaug/HEAD/imgaug/augmentables/segmaps.py |
Generate consistent docstrings | from __future__ import print_function, division, absolute_import
from abc import ABCMeta, abstractmethod
import functools
import six
import numpy as np
import imgaug as ia
from . import meta
from .. import parameters as iap
def _compute_shape_after_pooling(image_shape, ksize_h, ksize_w):
if any([axis == 0 for ... | --- +++ @@ -1,3 +1,14 @@+"""
+Augmenters that apply pooling operations to images.
+
+List of augmenters:
+
+ * :class:`AveragePooling`
+ * :class:`MaxPooling`
+ * :class:`MinPooling`
+ * :class:`MedianPooling`
+
+"""
from __future__ import print_function, division, absolute_import
from abc import ABCMet... | https://raw.githubusercontent.com/aleju/imgaug/HEAD/imgaug/augmenters/pooling.py |
Improve documentation using docstrings | from __future__ import print_function, division, absolute_import
import numpy as np
import scipy.spatial.distance
import six.moves as sm
from .. import imgaug as ia
from .base import IAugmentable
from .utils import (
normalize_imglike_shape,
project_coords,
_remove_out_of_image_fraction_,
_handle_on_i... | --- +++ @@ -1,3 +1,4 @@+"""Classes to represent keypoints, i.e. points given as xy-coordinates."""
from __future__ import print_function, division, absolute_import
import numpy as np
@@ -15,6 +16,27 @@
def compute_geometric_median(points=None, eps=1e-5, X=None):
+ """Estimate the geometric median of points i... | https://raw.githubusercontent.com/aleju/imgaug/HEAD/imgaug/augmentables/kps.py |
Add docstrings that explain purpose and usage | from __future__ import print_function, division, absolute_import
class IAugmentable(object): | --- +++ @@ -1,4 +1,21 @@+"""Interfaces used by augmentable objects.
+
+Added in 0.4.0.
+
+"""
from __future__ import print_function, division, absolute_import
-class IAugmentable(object):+class IAugmentable(object):
+ """Interface of augmentable objects.
+
+ This interface is right now only used to "mark" au... | https://raw.githubusercontent.com/aleju/imgaug/HEAD/imgaug/augmentables/base.py |
Add docstrings including usage examples | from __future__ import print_function, division, absolute_import
import collections
import numpy as np
from .. import imgaug as ia
from . import normalization as nlib
from . import utils
DEFAULT = "DEFAULT"
_AUGMENTABLE_NAMES = [
"images", "heatmaps", "segmentation_maps", "keypoints",
"bounding_boxes", "po... | --- +++ @@ -1,3 +1,4 @@+"""Classes representing batches of normalized or unnormalized data."""
from __future__ import print_function, division, absolute_import
import collections
@@ -42,10 +43,97 @@ # TODO also support (H,W,C) for heatmaps of len(images) == 1
# TODO also support (H,W) for segmaps of len(images) ==... | https://raw.githubusercontent.com/aleju/imgaug/HEAD/imgaug/augmentables/batches.py |
Add docstrings including usage examples | from __future__ import print_function, division, absolute_import
import copy
import numpy as np
import skimage.draw
import skimage.measure
from .. import imgaug as ia
from .base import IAugmentable
from .utils import (
normalize_imglike_shape,
project_coords,
_remove_out_of_image_fraction_,
_normaliz... | --- +++ @@ -1,3 +1,4 @@+"""Classes representing bounding boxes."""
from __future__ import print_function, division, absolute_import
import copy
@@ -19,8 +20,36 @@
# TODO functions: square(), to_aspect_ratio(), contains_point()
class BoundingBox(object):
+ """Class representing bounding boxes.
+
+ Each boun... | https://raw.githubusercontent.com/aleju/imgaug/HEAD/imgaug/augmentables/bbs.py |
Add docstrings for better understanding | from __future__ import print_function, division, absolute_import
import copy as copylib
import numpy as np
import skimage.draw
import skimage.measure
import cv2
from .. import imgaug as ia
from .base import IAugmentable
from .utils import (
normalize_imglike_shape,
project_coords_,
interpolate_points,
... | --- +++ @@ -1,3 +1,4 @@+"""Classes representing lines."""
from __future__ import print_function, division, absolute_import
import copy as copylib
@@ -24,8 +25,28 @@ # find_self_intersections(), is_self_intersecting(),
# remove_self_intersections()
class LineString(object):
+ """Class representing lin... | https://raw.githubusercontent.com/aleju/imgaug/HEAD/imgaug/augmentables/lines.py |
Generate docstrings for each module | from __future__ import print_function, division, absolute_import
import imgaug as ia
from . import blend
_DEPRECATION_COMMENT = (
"It has the same interface, except that the parameter "
"`first` was renamed to `foreground` and the parameter "
"`second` to `background`."
)
@ia.deprecated(alt_func="imgau... | --- +++ @@ -1,3 +1,8 @@+"""Alias for module blend.
+
+Deprecated module. Original name for module blend.py. Was changed in 0.2.8.
+
+"""
from __future__ import print_function, division, absolute_import
import imgaug as ia
@@ -14,6 +19,7 @@ @ia.deprecated(alt_func="imgaug.augmenters.blend.blend_alpha()",
... | https://raw.githubusercontent.com/aleju/imgaug/HEAD/imgaug/augmenters/overlay.py |
Write docstrings that follow conventions | from __future__ import print_function, division, absolute_import
import numpy as np
import six.moves as sm
import skimage.exposure as ski_exposure
import cv2
import imgaug as ia
from imgaug.imgaug import _normalize_cv2_input_arr_
from . import meta
from . import color as color_lib
from .. import parameters as iap
fro... | --- +++ @@ -1,3 +1,18 @@+"""
+Augmenters that perform contrast changes.
+
+List of augmenters:
+
+ * :class:`GammaContrast`
+ * :class:`SigmoidContrast`
+ * :class:`LogContrast`
+ * :class:`LinearContrast`
+ * :class:`AllChannelsHistogramEqualization`
+ * :class:`HistogramEqualization`
+ * :class:`... | https://raw.githubusercontent.com/aleju/imgaug/HEAD/imgaug/augmenters/contrast.py |
Expand my code with proper documentation strings | from __future__ import print_function, division, absolute_import
import numpy as np
import six.moves as sm
from .. import imgaug as ia
from .base import IAugmentable
class HeatmapsOnImage(IAugmentable):
def __init__(self, arr, shape, min_value=0.0, max_value=1.0):
assert ia.is_np_array(arr), (
... | --- +++ @@ -1,3 +1,4 @@+"""Classes to represent heatmaps, i.e. float arrays of ``[0.0, 1.0]``."""
from __future__ import print_function, division, absolute_import
import numpy as np
@@ -8,8 +9,39 @@
class HeatmapsOnImage(IAugmentable):
+ """Object representing heatmaps on a single image.
+
+ Parameters
+ ... | https://raw.githubusercontent.com/aleju/imgaug/HEAD/imgaug/augmentables/heatmaps.py |
Add inline docstrings for readability | from __future__ import print_function, division, absolute_import
import numpy as np
import imgaug as ia
from . import meta, arithmetic, blur, contrast, color as colorlib
from .. import parameters as iap
from .. import dtypes as iadt
class FastSnowyLandscape(meta.Augmenter):
def __init__(self, lightness_thresho... | --- +++ @@ -1,3 +1,18 @@+"""
+Augmenters that create weather effects.
+
+List of augmenters:
+
+ * :class:`FastSnowyLandscape`
+ * :class:`CloudLayer`
+ * :class:`Clouds`
+ * :class:`Fog`
+ * :class:`SnowflakesLayer`
+ * :class:`Snowflakes`
+ * :class:`RainLayer`
+ * :class:`Rain`
+
+"""
from _... | https://raw.githubusercontent.com/aleju/imgaug/HEAD/imgaug/augmenters/weather.py |
Improve documentation using docstrings | from __future__ import print_function, division, absolute_import
from abc import ABCMeta, abstractmethod
import numpy as np
# use skimage.segmentation instead `from skimage import segmentation` here,
# because otherwise unittest seems to mix up imgaug.augmenters.segmentation
# with skimage.segmentation for whatever r... | --- +++ @@ -1,3 +1,15 @@+"""
+Augmenters that apply changes to images based on segmentation methods.
+
+List of augmenters:
+
+ * :class:`Superpixels`
+ * :class:`Voronoi`
+ * :class:`UniformVoronoi`
+ * :class:`RegularGridVoronoi`
+ * :class:`RelativeRegularGridVoronoi`
+
+"""
from __future__ import pr... | https://raw.githubusercontent.com/aleju/imgaug/HEAD/imgaug/augmenters/segmentation.py |
Generate docstrings with examples | from __future__ import print_function, division, absolute_import
import numpy as np
import six.moves as sm
import imgaug as ia
KIND_TO_DTYPES = {
"i": ["int8", "int16", "int32", "int64"],
"u": ["uint8", "uint16", "uint32", "uint64"],
"b": ["bool"],
"f": ["float16", "float32", "float64", "float128"]
}... | --- +++ @@ -1,3 +1,4 @@+"""Functions to interact/analyze with numpy dtypes."""
from __future__ import print_function, division, absolute_import
import numpy as np
@@ -320,6 +321,28 @@
def gate_dtypes_strs(dtypes, allowed, disallowed, augmenter=None):
+ """Verify that input dtypes match allowed/disallowed dty... | https://raw.githubusercontent.com/aleju/imgaug/HEAD/imgaug/dtypes.py |
Write clean docstrings for readability | from __future__ import print_function, division, absolute_import
import sys
import multiprocessing
import threading
import traceback
import time
import random
import platform
import numpy as np
import cv2
import imgaug.imgaug as ia
import imgaug.random as iarandom
from imgaug.augmentables.batches import Batch, Unnorm... | --- +++ @@ -1,3 +1,4 @@+"""Classes and functions dealing with augmentation on multiple CPU cores."""
from __future__ import print_function, division, absolute_import
import sys
import multiprocessing
@@ -101,6 +102,34 @@
class Pool(object):
+ """
+ Wrapper around ``multiprocessing.Pool`` for multicore augm... | https://raw.githubusercontent.com/aleju/imgaug/HEAD/imgaug/multicore.py |
Write docstrings including parameters and return values | from __future__ import print_function, division, absolute_import
import copy as copylib
import numpy as np
import six.moves as sm
# Check if numpy is version 1.17 or later. In that version, the new random
# number interface was added.
# Note that a valid version number can also be "1.18.0.dev0+285ab1d",
# in which ... | --- +++ @@ -1,3 +1,43 @@+"""Classes and functions related to pseudo-random number generation.
+
+This module deals with the generation of pseudo-random numbers.
+It provides the :class:`~imgaug.random.RNG` class, which is the primary
+random number generator in ``imgaug``. It also provides various utility
+functions re... | https://raw.githubusercontent.com/aleju/imgaug/HEAD/imgaug/random.py |
Generate docstrings for script automation | from __future__ import print_function, division, absolute_import
import os
import json
import imageio
import numpy as np
# filepath to the quokka image, its annotations and depth map
# Added in 0.5.0.
_FILE_DIR = os.path.dirname(os.path.abspath(__file__))
# Added in 0.5.0.
_QUOKKA_FP = os.path.join(_FILE_DIR, "quokk... | --- +++ @@ -1,3 +1,8 @@+"""Functions to generate example data, e.g. example images or segmaps.
+
+Added in 0.5.0.
+
+"""
from __future__ import print_function, division, absolute_import
import os
@@ -19,6 +24,35 @@
def _quokka_normalize_extract(extract):
+ """Generate a normalized rectangle for the standard ... | https://raw.githubusercontent.com/aleju/imgaug/HEAD/imgaug/data.py |
Write docstrings for utility functions | from __future__ import print_function, division, absolute_import
import copy as copy_module
from collections import defaultdict
from abc import ABCMeta, abstractmethod
import tempfile
from functools import reduce, wraps
from operator import mul as mul_op
import numpy as np
import six
import six.moves as sm
import scip... | --- +++ @@ -1,3 +1,10 @@+"""Classes and methods to use for parameters of augmenters.
+
+This module contains e.g. classes representing probability
+distributions (guassian, poisson etc.), classes representing noise sources
+and methods to normalize parameter-related user inputs.
+
+"""
from __future__ import print_fun... | https://raw.githubusercontent.com/aleju/imgaug/HEAD/imgaug/parameters.py |
Improve my code by adding docstrings | from __future__ import print_function, division, absolute_import
import imgaug as ia
def convert_iterable_to_string_of_types(iterable_var):
types = [str(type(var_i)) for var_i in iterable_var]
return ", ".join(types)
def is_iterable_of(iterable_var, classes):
if not ia.is_iterable(iterable_var):
... | --- +++ @@ -1,14 +1,47 @@+"""Helper functions to validate input data and produce error messages."""
from __future__ import print_function, division, absolute_import
import imgaug as ia
def convert_iterable_to_string_of_types(iterable_var):
+ """Convert an iterable of values to a string of their types.
+
+ ... | https://raw.githubusercontent.com/aleju/imgaug/HEAD/imgaug/validation.py |
Add docstrings to clarify complex logic | from __future__ import print_function, division, absolute_import
import math
import numbers
import sys
import os
import types
import functools
# collections.abc exists since 3.3 and is expected to be used for 3.8+
try:
from collections.abc import Iterable
except ImportError:
from collections import Iterable
i... | --- +++ @@ -1,3 +1,4 @@+"""Collection of basic functions used throughout imgaug."""
from __future__ import print_function, division, absolute_import
import math
@@ -61,18 +62,77 @@ ###############################################################################
class DeprecationWarning(Warning): # pylint: disabl... | https://raw.githubusercontent.com/aleju/imgaug/HEAD/imgaug/imgaug.py |
Document functions with detailed explanations | # pylint: disable=missing-module-docstring
import re
from pkg_resources import get_distribution, DistributionNotFound
from setuptools import setup, find_packages
long_description = """A library for image augmentation in machine learning experiments, particularly convolutional
neural networks. Supports the augmentatio... | --- +++ @@ -27,6 +27,9 @@
def check_alternative_installation(install_require, alternative_install_requires):
+ """If some version version of alternative requirement installed, return alternative,
+ else return main.
+ """
for alternative_install_require in alternative_install_requires:
try:
... | https://raw.githubusercontent.com/aleju/imgaug/HEAD/setup.py |
Write documentation strings for class attributes |
# Based on: https://gist.github.com/KdotJPG/b1270127455a94ac5d19
import sys
from ctypes import c_long
from math import floor as _floor
if sys.version_info[0] < 3:
def floor(num):
return int(_floor(num))
else:
floor = _floor
STRETCH_CONSTANT_2D = -0.211324865405187 # (1/Math.sqrt(2+1)-1)/2
SQUIS... | --- +++ @@ -1,3 +1,7 @@+"""
+This is a copy of the OpenSimplex library,
+based on commit d861cb290531ad15825f21dc4cc35c5d4f407259 from 20.07.2017.
+"""
# Based on: https://gist.github.com/KdotJPG/b1270127455a94ac5d19
@@ -82,8 +86,14 @@
class OpenSimplex(object):
+ """
+ OpenSimplex n-dimensional gradient... | https://raw.githubusercontent.com/aleju/imgaug/HEAD/imgaug/external/opensimplex.py |
Create documentation for each function signature | # BentleyOttmann sweep-line implementation
# (for finding all intersections in a set of line segments)
__all__ = (
"isect_segments",
"isect_polygon",
# same as above but includes segments with each intersections
"isect_segments_include_segments",
"isect_polygon_include_segments",
# for testin... | --- +++ @@ -248,6 +248,9 @@ self._before = True
def get_intersections(self):
+ """
+ Return a list of unordered intersection points.
+ """
if Real is float:
return list(self.intersections.keys())
else:
@@ -255,6 +258,10 @@
# Not essential for impl... | https://raw.githubusercontent.com/aleju/imgaug/HEAD/imgaug/external/poly_point_isect_py2py3.py |
Expand my code with proper documentation strings | # vim:fileencoding=utf-8:noet
from __future__ import (unicode_literals, division, absolute_import, print_function)
from powerline.renderers.shell import ShellRenderer
from powerline.renderers.shell.readline import ReadlineRenderer
from powerline.renderers.ipython import IPythonRenderer
class IPythonPre50Renderer(IPy... | --- +++ @@ -7,6 +7,7 @@
class IPythonPre50Renderer(IPythonRenderer, ShellRenderer):
+ '''Powerline ipython segment renderer for pre-5.0 IPython versions.'''
def render(self, **kwargs):
# XXX super(ShellRenderer), *not* super(IPythonPre50Renderer)
return super(ShellRenderer, self).render(**kwargs)
@@ -20,14 ... | https://raw.githubusercontent.com/powerline/powerline/HEAD/powerline/renderers/ipython/pre_5.py |
Create docstrings for all classes and functions | # vim:fileencoding=utf-8:noet
from __future__ import (unicode_literals, division, absolute_import, print_function)
import operator
from collections import defaultdict
try:
from __builtin__ import reduce
except ImportError:
from functools import reduce
from pygments.token import Token
from prompt_toolkit.styles im... | --- +++ @@ -24,6 +24,8 @@ # Note: since 2.7 there is dict.__missing__ with same purpose. But in 2.6 one
# must use defaultdict to get __missing__ working.
class PowerlineStyleDict(defaultdict):
+ '''Dictionary used for getting pygments style for Powerline groups
+ '''
def __new__(cls, missing_func):
return defa... | https://raw.githubusercontent.com/powerline/powerline/HEAD/powerline/renderers/ipython/since_5.py |
Create documentation strings for testing functions | # vim:fileencoding=utf-8:noet
from __future__ import (unicode_literals, division, absolute_import, print_function)
from powerline.theme import requires_segment_info
from powerline.lib.dict import updated
from powerline.bindings.wm import get_i3_connection, get_connected_xrandr_outputs
@requires_segment_info
def outp... | --- +++ @@ -8,6 +8,8 @@
@requires_segment_info
def output_lister(pl, segment_info):
+ '''List all outputs in segment_info format
+ '''
return (
(
@@ -22,6 +24,24 @@
@requires_segment_info
def workspace_lister(pl, segment_info, only_show=None, output=None):
+ '''List all workspaces in segment_info format
+
... | https://raw.githubusercontent.com/powerline/powerline/HEAD/powerline/listers/i3wm.py |
Add detailed docstrings explaining each function | # vim:fileencoding=utf-8:noet
from __future__ import (unicode_literals, division, absolute_import, print_function)
import sys
import os
from subprocess import Popen, PIPE
from functools import partial
from powerline.lib.encoding import get_preferred_input_encoding, get_preferred_output_encoding
if sys.platform.sta... | --- +++ @@ -17,6 +17,19 @@
def run_cmd(pl, cmd, stdin=None, strip=True):
+ '''Run command and return its stdout, stripped
+
+ If running command fails returns None and logs failure to ``pl`` argument.
+
+ :param PowerlineLogger pl:
+ Logger used to log failures.
+ :param list cmd:
+ Command which will be run.
+ :... | https://raw.githubusercontent.com/powerline/powerline/HEAD/powerline/lib/shell.py |
Generate helpful docstrings for debugging | # vim:fileencoding=utf-8:noet
from __future__ import (unicode_literals, division, absolute_import, print_function)
import json
from powerline.lib.dict import REMOVE_THIS_KEY
def parse_value(s):
if not s:
return REMOVE_THIS_KEY
elif s[0] in '"{[0123456789-' or s in ('null', 'true', 'false'):
return json.loads(... | --- +++ @@ -7,6 +7,22 @@
def parse_value(s):
+ '''Convert string to Python object
+
+ Rules:
+
+ * Empty string means that corresponding key should be removed from the
+ dictionary.
+ * Strings that start with a minus, digit or with some character that starts
+ JSON collection or string object are parsed as J... | https://raw.githubusercontent.com/powerline/powerline/HEAD/powerline/lib/overrides.py |
Add docstrings to incomplete code | # vim:fileencoding=utf-8:noet
from __future__ import (unicode_literals, division, absolute_import, print_function)
import os
import sys
import logging
from threading import Lock, Event
from powerline.colorscheme import Colorscheme
from powerline.lib.config import ConfigLoader
from powerline.lib.unicode import unicod... | --- +++ @@ -44,6 +44,23 @@
class PowerlineLogger(object):
+ '''Proxy class for logging.Logger instance
+
+ It emits messages in format ``{ext}:{prefix}:{message}`` where
+
+ ``{ext}``
+ is a used powerline extension (e.g. “vim”, “shell”, “ipython”).
+ ``{prefix}``
+ is a local prefix, usually a segment name.
+ ``... | https://raw.githubusercontent.com/powerline/powerline/HEAD/powerline/__init__.py |
Write docstrings for algorithm functions | # vim:fileencoding=utf-8:noet
from __future__ import (unicode_literals, division, absolute_import, print_function)
import re
import os
import subprocess
from collections import namedtuple
from powerline.lib.shell import run_cmd
TmuxVersionInfo = namedtuple('TmuxVersionInfo', ('major', 'minor', 'suffix'))
def get... | --- +++ @@ -14,6 +14,11 @@
def get_tmux_executable_name():
+ '''Returns tmux executable name
+
+ It should be defined in POWERLINE_TMUX_EXE environment variable, otherwise
+ it is simply “tmux”.
+ '''
return os.environ.get('POWERLINE_TMUX_EXE', 'tmux')
@@ -23,14 +28,26 @@
def run_tmux_command(*args):
+ '... | https://raw.githubusercontent.com/powerline/powerline/HEAD/powerline/bindings/tmux/__init__.py |
Provide docstrings following PEP 257 | # vim:fileencoding=utf-8:noet
from __future__ import (unicode_literals, division, absolute_import, print_function)
import re
from powerline.theme import requires_segment_info
from powerline.lib.shell import run_cmd
from powerline.bindings.wm.awesome import AwesomeThread
DEFAULT_UPDATE_INTERVAL = 0.5
conn = None
... | --- +++ @@ -15,6 +15,15 @@
def i3_subscribe(conn, event, callback):
+ '''Subscribe to i3 workspace event
+
+ :param conn:
+ Connection returned by :py:func:`get_i3_connection`.
+ :param str event:
+ Event to subscribe to, e.g. ``'workspace'``.
+ :param func callback:
+ Function to run on event.
+ '''
conn.on(e... | https://raw.githubusercontent.com/powerline/powerline/HEAD/powerline/bindings/wm/__init__.py |
Document functions with clear intent | # vim:fileencoding=utf-8:noet
from __future__ import (unicode_literals, division, absolute_import, print_function)
import sys
import pdb
from powerline.pdb import PDBPowerline
from powerline.lib.encoding import get_preferred_output_encoding
from powerline.lib.unicode import unicode
if sys.version_info < (3,):
# XX... | --- +++ @@ -123,6 +123,15 @@
def use_powerline_prompt(cls):
+ '''Decorator that installs powerline prompt to the class
+
+ :param pdb.Pdb cls:
+ Class that should be decorated.
+
+ :return:
+ ``cls`` argument or a class derived from it. Latter is used to turn
+ old-style classes into new-style classes.
+ '''
... | https://raw.githubusercontent.com/powerline/powerline/HEAD/powerline/bindings/pdb/__init__.py |
Generate NumPy-style docstrings | # vim:fileencoding=utf-8:noet
from __future__ import (unicode_literals, division, absolute_import, print_function)
import errno
import os
import ctypes
from threading import RLock
from powerline.lib.inotify import INotify
from powerline.lib.monotonic import monotonic
from powerline.lib.path import realpath
class I... | --- +++ @@ -67,6 +67,8 @@ self.modified[path] = True
def unwatch(self, path):
+ ''' Remove the watch for path. Raises an OSError if removing the watch
+ fails for some reason. '''
path = realpath(path)
with self.lock:
self.modified.pop(path, None)
@@ -77,6 +79,8 @@ self.handle_error()
def... | https://raw.githubusercontent.com/powerline/powerline/HEAD/powerline/lib/watcher/inotify.py |
Write docstrings describing each step | # vim:fileencoding=utf-8:noet
from __future__ import (unicode_literals, division, absolute_import, print_function)
REMOVE_THIS_KEY = object()
def mergeargs(argvalue, remove=False):
if not argvalue:
return None
r = {}
for subval in argvalue:
mergedicts(r, dict([subval]), remove=remove)
return r
def _clear_... | --- +++ @@ -15,6 +15,8 @@
def _clear_special_values(d):
+ '''Remove REMOVE_THIS_KEY values from dictionary
+ '''
l = [d]
while l:
i = l.pop()
@@ -29,6 +31,10 @@
def mergedicts(d1, d2, remove=True):
+ '''Recursively merge two dictionaries
+
+ First dictionary is modified in-place.
+ '''
_setmerged(d1, d... | https://raw.githubusercontent.com/powerline/powerline/HEAD/powerline/lib/dict.py |
Document this module using docstrings | # vim:fileencoding=utf-8:noet
from __future__ import (unicode_literals, division, absolute_import, print_function)
from powerline.theme import requires_segment_info
from powerline.bindings.vim import (current_tabpage, list_tabpages)
try:
import vim
except ImportError:
vim = object()
def tabpage_updated_segment_in... | --- +++ @@ -28,6 +28,17 @@
@requires_segment_info
def tablister(pl, segment_info, **kwargs):
+ '''List all tab pages in segment_info format
+
+ Specifically generates a list of segment info dictionaries with ``window``,
+ ``winnr``, ``window_id``, ``buffer`` and ``bufnr`` keys set to tab-local
+ ones and additiona... | https://raw.githubusercontent.com/powerline/powerline/HEAD/powerline/listers/vim.py |
Write docstrings including parameters and return values | # vim:fileencoding=utf-8:noet
from __future__ import (unicode_literals, division, absolute_import, print_function)
from copy import copy
from powerline.lib.unicode import unicode
DEFAULT_MODE_KEY = None
ATTR_BOLD = 1
ATTR_ITALIC = 2
ATTR_UNDERLINE = 4
def get_attrs_flag(attrs):
attrs_flag = 0
if 'bold' in attrs... | --- +++ @@ -13,6 +13,7 @@
def get_attrs_flag(attrs):
+ '''Convert an attribute array to a renderer flag.'''
attrs_flag = 0
if 'bold' in attrs:
attrs_flag |= ATTR_BOLD
@@ -24,11 +25,16 @@
def pick_gradient_value(grad_list, gradient_level):
+ '''Given a list of colors and gradient percent, return a color t... | https://raw.githubusercontent.com/powerline/powerline/HEAD/powerline/colorscheme.py |
Write reusable docstrings | # vim:fileencoding=utf-8:noet
from __future__ import (unicode_literals, division, absolute_import, print_function)
import json
import codecs
from copy import deepcopy
from threading import Event, Lock
from collections import defaultdict
from powerline.lib.threaded import MultiRunnedThread
from powerline.lib.watcher ... | --- +++ @@ -92,15 +92,45 @@ self.interval = interval
def register(self, function, path):
+ '''Register function that will be run when file changes.
+
+ :param function function:
+ Function that will be called when file at the given path changes.
+ :param str path:
+ Path that will be watched for.
+ '''
... | https://raw.githubusercontent.com/powerline/powerline/HEAD/powerline/lib/config.py |
Add docstrings that explain purpose and usage | # vim:fileencoding=utf-8:noet
from __future__ import (unicode_literals, division, absolute_import, print_function)
import itertools
import re
from copy import copy
from powerline.lib.unicode import unicode
from powerline.lint.markedjson.error import echoerr, DelayedEchoErr, NON_PRINTABLE_STR
from powerline.lint.self... | --- +++ @@ -21,6 +21,50 @@
class Spec(object):
+ '''Class that describes some JSON value
+
+ In powerline it is only used to describe JSON values stored in powerline
+ configuration.
+
+ :param dict keys:
+ Dictionary that maps keys that may be present in the given JSON
+ dictionary to their descriptions. If th... | https://raw.githubusercontent.com/powerline/powerline/HEAD/powerline/lint/spec.py |
Add docstrings to improve code quality | # vim:fileencoding=utf-8:noet
from __future__ import (unicode_literals, division, absolute_import, print_function)
import sys
import os
import re
import operator
from itertools import chain
from powerline.theme import Theme
from powerline.lib.unicode import unichr, strwidth_ucs_2, strwidth_ucs_4
NBSP = ' '
np_co... | --- +++ @@ -101,6 +101,24 @@
class Renderer(object):
+ '''Object that is responsible for generating the highlighted string.
+
+ :param dict theme_config:
+ Main theme configuration.
+ :param local_themes:
+ Local themes. Is to be used by subclasses from ``.get_theme()`` method,
+ base class only records this par... | https://raw.githubusercontent.com/powerline/powerline/HEAD/powerline/renderer.py |
Write docstrings for algorithm functions | # vim:fileencoding=utf-8:noet
from __future__ import (unicode_literals, division, absolute_import, print_function)
import os
import re
import sys
import subprocess
import shlex
from powerline.config import POWERLINE_ROOT, TMUX_CONFIG_DIRECTORY
from powerline.lib.config import ConfigLoader
from powerline import genera... | --- +++ @@ -33,6 +33,7 @@
def list_all_tmux_configs():
+ '''List all version-specific tmux configuration files'''
for root, dirs, files in os.walk(TMUX_CONFIG_DIRECTORY):
dirs[:] = ()
for fname in files:
@@ -52,12 +53,23 @@
def get_tmux_configs(version):
+ '''Get tmux configuration suffix given parsed t... | https://raw.githubusercontent.com/powerline/powerline/HEAD/powerline/bindings/config.py |
Write clean docstrings for readability | # vim:fileencoding=utf-8:noet
from __future__ import (unicode_literals, division, absolute_import, print_function)
import sys
import codecs
from unicodedata import east_asian_width, combining
from powerline.lib.encoding import get_preferred_output_encoding
try:
from __builtin__ import unicode
except ImportError:
... | --- +++ @@ -33,6 +33,8 @@
def u(s):
+ '''Return unicode instance assuming UTF-8 encoded string.
+ '''
if type(s) is unicode:
return s
else:
@@ -41,9 +43,13 @@
if sys.version_info < (3,):
def tointiter(s):
+ '''Convert a byte string to the sequence of integers
+ '''
return (ord(c) for c in s)
else:
... | https://raw.githubusercontent.com/powerline/powerline/HEAD/powerline/lib/unicode.py |
Help me document legacy Python code | # vim:fileencoding=utf-8:noet
from __future__ import (unicode_literals, division, absolute_import, print_function)
import sys
from powerline.lib.watcher.stat import StatFileWatcher
from powerline.lib.watcher.inotify import INotifyFileWatcher
from powerline.lib.watcher.tree import TreeWatcher
from powerline.lib.watche... | --- +++ @@ -11,6 +11,28 @@
def create_file_watcher(pl, watcher_type='auto', expire_time=10):
+ '''Create an object that can watch for changes to specified files
+
+ Use ``.__call__()`` method of the returned object to start watching the file
+ or check whether file has changed since last call.
+
+ Use ``.unwatch()... | https://raw.githubusercontent.com/powerline/powerline/HEAD/powerline/lib/watcher/__init__.py |
Generate docstrings for script automation | # vim:fileencoding=utf-8:noet
from __future__ import (unicode_literals, division, absolute_import, print_function)
import os
import re
import logging
from collections import defaultdict
from powerline.lib.threaded import ThreadedSegment
from powerline.lib.unicode import unicode
from powerline.lint.markedjson.markedv... | --- +++ @@ -352,6 +352,19 @@
def check_hl_group_name(hl_group, context_mark, context, echoerr):
+ '''Check highlight group name: it should match naming conventions
+
+ :param str hl_group:
+ Checked group.
+ :param Mark context_mark:
+ Context mark. May be ``None``.
+ :param Context context:
+ Current context.
+... | https://raw.githubusercontent.com/powerline/powerline/HEAD/powerline/lint/checks.py |
Add docstrings that explain purpose and usage | # vim:fileencoding=utf-8:noet
from __future__ import (unicode_literals, division, absolute_import, print_function)
import sys
import locale
def get_preferred_file_name_encoding():
return (
sys.getfilesystemencoding()
or locale.getpreferredencoding()
or 'utf-8'
)
def get_preferred_file_contents_encoding()... | --- +++ @@ -1,5 +1,15 @@ # vim:fileencoding=utf-8:noet
+'''Encodings support
+
+This is the only module from which functions obtaining encoding should be
+exported. Note: you should always care about errors= argument since it is not
+guaranteed that encoding returned by some function can encode/decode given
+strin... | https://raw.githubusercontent.com/powerline/powerline/HEAD/powerline/lib/encoding.py |
Annotate my code with docstrings | # vim:fileencoding=utf-8:noet
from __future__ import (unicode_literals, division, absolute_import, print_function)
from powerline.renderer import Renderer
from powerline.theme import Theme
from powerline.colorscheme import ATTR_BOLD, ATTR_ITALIC, ATTR_UNDERLINE
def int_to_rgb(num):
r = (num >> 16) & 0xff
g = (num ... | --- +++ @@ -14,12 +14,25 @@
class PromptRenderer(Renderer):
+ '''Powerline generic prompt segment renderer'''
def __init__(self, old_widths=None, **kwargs):
super(PromptRenderer, self).__init__(**kwargs)
self.old_widths = old_widths if old_widths is not None else {}
def get_client_id(self, segment_inf... | https://raw.githubusercontent.com/powerline/powerline/HEAD/powerline/renderers/shell/__init__.py |
Create documentation strings for testing functions | # vim:fileencoding=utf-8:noet
from __future__ import (unicode_literals, division, absolute_import, print_function)
from powerline.theme import requires_segment_info
from powerline.segments import with_docstring
from powerline.segments.common.env import CwdSegment
from powerline.lib.unicode import out_u
@requires_seg... | --- +++ @@ -9,6 +9,12 @@
@requires_segment_info
def jobnum(pl, segment_info, show_zero=False):
+ '''Return the number of jobs.
+
+ :param bool show_zero:
+ If False (default) shows nothing if there are no jobs. Otherwise shows
+ zero for no jobs.
+ '''
jobnum = segment_info['args'].jobnum
if jobnum is None or ... | https://raw.githubusercontent.com/powerline/powerline/HEAD/powerline/segments/shell.py |
Add detailed documentation for each class | # vim:fileencoding=utf-8:noet
from __future__ import (unicode_literals, division, absolute_import, print_function)
import sys
import platform
from powerline.renderers.shell.readline import ReadlineRenderer
from powerline.renderer import Renderer
class PDBRenderer(ReadlineRenderer):
pdb = None
initial_stack_length... | --- +++ @@ -9,6 +9,8 @@
class PDBRenderer(ReadlineRenderer):
+ '''PDB-specific powerline renderer
+ '''
pdb = None
initial_stack_length = None
@@ -20,6 +22,15 @@ return r
def set_pdb(self, pdb):
+ '''Record currently used :py:class:`pdb.Pdb` instance
+
+ Must be called before first calling :py:meth:`r... | https://raw.githubusercontent.com/powerline/powerline/HEAD/powerline/renderers/pdb.py |
Write documentation strings for class attributes | # vim:fileencoding=utf-8:noet
from __future__ import (unicode_literals, division, absolute_import, print_function)
try:
import vim
except ImportError:
vim = object()
from powerline.bindings.vim import create_ruby_dpowerline
def initialize():
global initialized
if initialized:
return
initialized = True
creat... | --- +++ @@ -44,6 +44,15 @@
def finder(pl):
+ '''Display Command-T finder name
+
+ Requires $command_t.active_finder and methods (code above may monkey-patch
+ $command_t to add them). All Command-T finders have ``CommandT::`` module
+ prefix, but it is stripped out (actually, any ``CommandT::`` substring will
+ ... | https://raw.githubusercontent.com/powerline/powerline/HEAD/powerline/segments/vim/plugin/commandt.py |
Document all endpoints with docstrings | # vim:fileencoding=utf-8:noet
from __future__ import (unicode_literals, division, absolute_import, print_function)
import sys
import vim
from powerline.bindings.vim import vim_get_func, vim_getoption, environ, current_tabpage, get_vim_encoding
from powerline.renderer import Renderer
from powerline.colorscheme import... | --- +++ @@ -24,6 +24,7 @@
class VimRenderer(Renderer):
+ '''Powerline vim segment renderer.'''
character_translations = Renderer.character_translations.copy()
character_translations[ord('%')] = '%%'
@@ -85,6 +86,7 @@ return segment_info or self.segment_info
def render(self, window=None, window_id=None, ... | https://raw.githubusercontent.com/powerline/powerline/HEAD/powerline/renderers/vim.py |
Add docstrings to make code maintainable | # vim:fileencoding=utf-8:noet
from __future__ import (unicode_literals, division, absolute_import, print_function)
import os
from multiprocessing import cpu_count as _cpu_count
from powerline.lib.threaded import ThreadedSegment
from powerline.lib import add_divider_highlight_group
from powerline.segments import with... | --- +++ @@ -15,6 +15,34 @@
def system_load(pl, format='{avg:.1f}', threshold_good=1, threshold_bad=2,
track_cpu_count=False, short=False):
+ '''Return system load average.
+
+ Highlights using ``system_load_good``, ``system_load_bad`` and
+ ``system_load_ugly`` highlighting groups, depending on the t... | https://raw.githubusercontent.com/powerline/powerline/HEAD/powerline/segments/common/sys.py |
Fully document this Python code with docstrings | # vim:fileencoding=utf-8:noet
from __future__ import (unicode_literals, division, absolute_import, print_function)
import sys
from pkgutil import extend_path
from types import MethodType
__path__ = extend_path(__path__, __name__)
class Segment(object):
if sys.version_info < (3, 4):
def argspecobjs(self):
yi... | --- +++ @@ -11,6 +11,17 @@
class Segment(object):
+ '''Base class for any segment that is not a function
+
+ Required for powerline.lint.inspect to work properly: it defines methods for
+ omitting existing or adding new arguments.
+
+ .. note::
+ Until python-3.4 ``inspect.getargspec`` does not support querying
... | https://raw.githubusercontent.com/powerline/powerline/HEAD/powerline/segments/__init__.py |
Create documentation for each function signature | # vim:fileencoding=utf-8:noet
from __future__ import (unicode_literals, division, absolute_import, print_function)
import os
from powerline.lib.unicode import out_u
from powerline.theme import requires_segment_info
from powerline.segments import Segment, with_docstring
@requires_segment_info
def environment(pl, seg... | --- +++ @@ -10,11 +10,24 @@
@requires_segment_info
def environment(pl, segment_info, variable=None):
+ '''Return the value of any defined environment variable
+
+ :param string variable:
+ The environment variable to return if found
+ '''
return segment_info['environ'].get(variable, None)
@requires_segment_i... | https://raw.githubusercontent.com/powerline/powerline/HEAD/powerline/segments/common/env.py |
Add verbose docstrings with examples | # vim:fileencoding=utf-8:noet
from datetime import datetime, timezone
def date(pl, format='%Y-%m-%d', istime=False, timezone=None):
try:
tz = datetime.strptime(timezone, '%z').tzinfo if timezone else None
except ValueError:
tz = None
nw = datetime.now(tz)
try:
contents = nw.strftime(format)
except Unico... | --- +++ @@ -3,6 +3,20 @@
def date(pl, format='%Y-%m-%d', istime=False, timezone=None):
+ '''Return the current date.
+
+ :param str format:
+ strftime-style date format string
+ :param bool istime:
+ If true then segment uses ``time`` highlight group.
+ :param string timezone:
+ Specify a timezone to use as ``+H... | https://raw.githubusercontent.com/powerline/powerline/HEAD/powerline/segments/common/time.py |
Write documentation strings for class attributes | # vim:fileencoding=utf-8:noet
from __future__ import (unicode_literals, division, absolute_import, print_function)
import sys
import json
import logging
from itertools import count
try:
import vim
except ImportError:
vim = object()
from powerline.bindings.vim import vim_get_func, vim_getvar, get_vim_encoding, pyt... | --- +++ @@ -33,6 +33,11 @@
class VimVarHandler(logging.Handler, object):
+ '''Vim-specific handler which emits messages to Vim global variables
+
+ :param str varname:
+ Variable where
+ '''
def __init__(self, varname):
super(VimVarHandler, self).__init__()
utf_varname = u(varname)
@@ -87,6 +92,24 @@ defa... | https://raw.githubusercontent.com/powerline/powerline/HEAD/powerline/vim.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.