partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
valid | GeoIP.time_zone_by_addr | Returns time zone in tzdata format (e.g. America/New_York or Europe/Paris)
:arg addr: IP address (e.g. 203.0.113.30) | pygeoip/__init__.py | def time_zone_by_addr(self, addr):
"""
Returns time zone in tzdata format (e.g. America/New_York or Europe/Paris)
:arg addr: IP address (e.g. 203.0.113.30)
"""
if self._databaseType not in const.CITY_EDITIONS:
message = 'Invalid database type, expected City'
... | def time_zone_by_addr(self, addr):
"""
Returns time zone in tzdata format (e.g. America/New_York or Europe/Paris)
:arg addr: IP address (e.g. 203.0.113.30)
"""
if self._databaseType not in const.CITY_EDITIONS:
message = 'Invalid database type, expected City'
... | [
"Returns",
"time",
"zone",
"in",
"tzdata",
"format",
"(",
"e",
".",
"g",
".",
"America",
"/",
"New_York",
"or",
"Europe",
"/",
"Paris",
")"
] | appliedsec/pygeoip | python | https://github.com/appliedsec/pygeoip/blob/2a725df0b727e8b08f217ab84f7b8243c42554f5/pygeoip/__init__.py#L586-L597 | [
"def",
"time_zone_by_addr",
"(",
"self",
",",
"addr",
")",
":",
"if",
"self",
".",
"_databaseType",
"not",
"in",
"const",
".",
"CITY_EDITIONS",
":",
"message",
"=",
"'Invalid database type, expected City'",
"raise",
"GeoIPError",
"(",
"message",
")",
"ipnum",
"=... | 2a725df0b727e8b08f217ab84f7b8243c42554f5 |
valid | GeoIP.time_zone_by_name | Returns time zone in tzdata format (e.g. America/New_York or Europe/Paris)
:arg hostname: Hostname (e.g. example.com) | pygeoip/__init__.py | def time_zone_by_name(self, hostname):
"""
Returns time zone in tzdata format (e.g. America/New_York or Europe/Paris)
:arg hostname: Hostname (e.g. example.com)
"""
addr = self._gethostbyname(hostname)
return self.time_zone_by_addr(addr) | def time_zone_by_name(self, hostname):
"""
Returns time zone in tzdata format (e.g. America/New_York or Europe/Paris)
:arg hostname: Hostname (e.g. example.com)
"""
addr = self._gethostbyname(hostname)
return self.time_zone_by_addr(addr) | [
"Returns",
"time",
"zone",
"in",
"tzdata",
"format",
"(",
"e",
".",
"g",
".",
"America",
"/",
"New_York",
"or",
"Europe",
"/",
"Paris",
")"
] | appliedsec/pygeoip | python | https://github.com/appliedsec/pygeoip/blob/2a725df0b727e8b08f217ab84f7b8243c42554f5/pygeoip/__init__.py#L599-L606 | [
"def",
"time_zone_by_name",
"(",
"self",
",",
"hostname",
")",
":",
"addr",
"=",
"self",
".",
"_gethostbyname",
"(",
"hostname",
")",
"return",
"self",
".",
"time_zone_by_addr",
"(",
"addr",
")"
] | 2a725df0b727e8b08f217ab84f7b8243c42554f5 |
valid | time_zone_by_country_and_region | Returns time zone from country and region code.
:arg country_code: Country code
:arg region_code: Region code | pygeoip/timezone.py | def time_zone_by_country_and_region(country_code, region_code=None):
"""
Returns time zone from country and region code.
:arg country_code: Country code
:arg region_code: Region code
"""
timezone = country_dict.get(country_code)
if not timezone:
return None
if isinstance(timezo... | def time_zone_by_country_and_region(country_code, region_code=None):
"""
Returns time zone from country and region code.
:arg country_code: Country code
:arg region_code: Region code
"""
timezone = country_dict.get(country_code)
if not timezone:
return None
if isinstance(timezo... | [
"Returns",
"time",
"zone",
"from",
"country",
"and",
"region",
"code",
"."
] | appliedsec/pygeoip | python | https://github.com/appliedsec/pygeoip/blob/2a725df0b727e8b08f217ab84f7b8243c42554f5/pygeoip/timezone.py#L19-L33 | [
"def",
"time_zone_by_country_and_region",
"(",
"country_code",
",",
"region_code",
"=",
"None",
")",
":",
"timezone",
"=",
"country_dict",
".",
"get",
"(",
"country_code",
")",
"if",
"not",
"timezone",
":",
"return",
"None",
"if",
"isinstance",
"(",
"timezone",
... | 2a725df0b727e8b08f217ab84f7b8243c42554f5 |
valid | BaseCompressor.compress | Compress a file, only if needed. | sigal/plugins/compress_assets.py | def compress(self, filename):
"""Compress a file, only if needed."""
compressed_filename = self.get_compressed_filename(filename)
if not compressed_filename:
return
self.do_compress(filename, compressed_filename) | def compress(self, filename):
"""Compress a file, only if needed."""
compressed_filename = self.get_compressed_filename(filename)
if not compressed_filename:
return
self.do_compress(filename, compressed_filename) | [
"Compress",
"a",
"file",
"only",
"if",
"needed",
"."
] | saimn/sigal | python | https://github.com/saimn/sigal/blob/912ca39991355d358dc85fd55c7aeabdd7acc386/sigal/plugins/compress_assets.py#L60-L66 | [
"def",
"compress",
"(",
"self",
",",
"filename",
")",
":",
"compressed_filename",
"=",
"self",
".",
"get_compressed_filename",
"(",
"filename",
")",
"if",
"not",
"compressed_filename",
":",
"return",
"self",
".",
"do_compress",
"(",
"filename",
",",
"compressed_... | 912ca39991355d358dc85fd55c7aeabdd7acc386 |
valid | BaseCompressor.get_compressed_filename | If the given filename should be compressed, returns the
compressed filename.
A file can be compressed if:
- It is a whitelisted extension
- The compressed file does not exist
- The compressed file exists by is older than the file itself
Otherwise, it returns False. | sigal/plugins/compress_assets.py | def get_compressed_filename(self, filename):
"""If the given filename should be compressed, returns the
compressed filename.
A file can be compressed if:
- It is a whitelisted extension
- The compressed file does not exist
- The compressed file exists by is older than t... | def get_compressed_filename(self, filename):
"""If the given filename should be compressed, returns the
compressed filename.
A file can be compressed if:
- It is a whitelisted extension
- The compressed file does not exist
- The compressed file exists by is older than t... | [
"If",
"the",
"given",
"filename",
"should",
"be",
"compressed",
"returns",
"the",
"compressed",
"filename",
"."
] | saimn/sigal | python | https://github.com/saimn/sigal/blob/912ca39991355d358dc85fd55c7aeabdd7acc386/sigal/plugins/compress_assets.py#L68-L98 | [
"def",
"get_compressed_filename",
"(",
"self",
",",
"filename",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"splitext",
"(",
"filename",
")",
"[",
"1",
"]",
"[",
"1",
":",
"]",
"in",
"self",
".",
"suffixes_to_compress",
":",
"return",
"False",
"file... | 912ca39991355d358dc85fd55c7aeabdd7acc386 |
valid | copy | Copy or symlink the file. | sigal/utils.py | def copy(src, dst, symlink=False, rellink=False):
"""Copy or symlink the file."""
func = os.symlink if symlink else shutil.copy2
if symlink and os.path.lexists(dst):
os.remove(dst)
if rellink: # relative symlink from dst
func(os.path.relpath(src, os.path.dirname(dst)), dst)
else:
... | def copy(src, dst, symlink=False, rellink=False):
"""Copy or symlink the file."""
func = os.symlink if symlink else shutil.copy2
if symlink and os.path.lexists(dst):
os.remove(dst)
if rellink: # relative symlink from dst
func(os.path.relpath(src, os.path.dirname(dst)), dst)
else:
... | [
"Copy",
"or",
"symlink",
"the",
"file",
"."
] | saimn/sigal | python | https://github.com/saimn/sigal/blob/912ca39991355d358dc85fd55c7aeabdd7acc386/sigal/utils.py#L45-L53 | [
"def",
"copy",
"(",
"src",
",",
"dst",
",",
"symlink",
"=",
"False",
",",
"rellink",
"=",
"False",
")",
":",
"func",
"=",
"os",
".",
"symlink",
"if",
"symlink",
"else",
"shutil",
".",
"copy2",
"if",
"symlink",
"and",
"os",
".",
"path",
".",
"lexist... | 912ca39991355d358dc85fd55c7aeabdd7acc386 |
valid | url_from_path | Transform path to url, converting backslashes to slashes if needed. | sigal/utils.py | def url_from_path(path):
"""Transform path to url, converting backslashes to slashes if needed."""
if os.sep != '/':
path = '/'.join(path.split(os.sep))
return quote(path) | def url_from_path(path):
"""Transform path to url, converting backslashes to slashes if needed."""
if os.sep != '/':
path = '/'.join(path.split(os.sep))
return quote(path) | [
"Transform",
"path",
"to",
"url",
"converting",
"backslashes",
"to",
"slashes",
"if",
"needed",
"."
] | saimn/sigal | python | https://github.com/saimn/sigal/blob/912ca39991355d358dc85fd55c7aeabdd7acc386/sigal/utils.py#L63-L68 | [
"def",
"url_from_path",
"(",
"path",
")",
":",
"if",
"os",
".",
"sep",
"!=",
"'/'",
":",
"path",
"=",
"'/'",
".",
"join",
"(",
"path",
".",
"split",
"(",
"os",
".",
"sep",
")",
")",
"return",
"quote",
"(",
"path",
")"
] | 912ca39991355d358dc85fd55c7aeabdd7acc386 |
valid | read_markdown | Reads markdown file, converts output and fetches title and meta-data for
further processing. | sigal/utils.py | def read_markdown(filename):
"""Reads markdown file, converts output and fetches title and meta-data for
further processing.
"""
global MD
# Use utf-8-sig codec to remove BOM if it is present. This is only possible
# this way prior to feeding the text to the markdown parser (which would
# al... | def read_markdown(filename):
"""Reads markdown file, converts output and fetches title and meta-data for
further processing.
"""
global MD
# Use utf-8-sig codec to remove BOM if it is present. This is only possible
# this way prior to feeding the text to the markdown parser (which would
# al... | [
"Reads",
"markdown",
"file",
"converts",
"output",
"and",
"fetches",
"title",
"and",
"meta",
"-",
"data",
"for",
"further",
"processing",
"."
] | saimn/sigal | python | https://github.com/saimn/sigal/blob/912ca39991355d358dc85fd55c7aeabdd7acc386/sigal/utils.py#L71-L106 | [
"def",
"read_markdown",
"(",
"filename",
")",
":",
"global",
"MD",
"# Use utf-8-sig codec to remove BOM if it is present. This is only possible",
"# this way prior to feeding the text to the markdown parser (which would",
"# also default to pure utf-8)",
"with",
"open",
"(",
"filename",
... | 912ca39991355d358dc85fd55c7aeabdd7acc386 |
valid | load_exif | Loads the exif data of all images in an album from cache | sigal/plugins/extended_caching.py | def load_exif(album):
"""Loads the exif data of all images in an album from cache"""
if not hasattr(album.gallery, "exifCache"):
_restore_cache(album.gallery)
cache = album.gallery.exifCache
for media in album.medias:
if media.type == "image":
key = os.path.join(media.path, ... | def load_exif(album):
"""Loads the exif data of all images in an album from cache"""
if not hasattr(album.gallery, "exifCache"):
_restore_cache(album.gallery)
cache = album.gallery.exifCache
for media in album.medias:
if media.type == "image":
key = os.path.join(media.path, ... | [
"Loads",
"the",
"exif",
"data",
"of",
"all",
"images",
"in",
"an",
"album",
"from",
"cache"
] | saimn/sigal | python | https://github.com/saimn/sigal/blob/912ca39991355d358dc85fd55c7aeabdd7acc386/sigal/plugins/extended_caching.py#L40-L50 | [
"def",
"load_exif",
"(",
"album",
")",
":",
"if",
"not",
"hasattr",
"(",
"album",
".",
"gallery",
",",
"\"exifCache\"",
")",
":",
"_restore_cache",
"(",
"album",
".",
"gallery",
")",
"cache",
"=",
"album",
".",
"gallery",
".",
"exifCache",
"for",
"media"... | 912ca39991355d358dc85fd55c7aeabdd7acc386 |
valid | _restore_cache | Restores the exif data cache from the cache file | sigal/plugins/extended_caching.py | def _restore_cache(gallery):
"""Restores the exif data cache from the cache file"""
cachePath = os.path.join(gallery.settings["destination"], ".exif_cache")
try:
if os.path.exists(cachePath):
with open(cachePath, "rb") as cacheFile:
gallery.exifCache = pickle.load(cacheFi... | def _restore_cache(gallery):
"""Restores the exif data cache from the cache file"""
cachePath = os.path.join(gallery.settings["destination"], ".exif_cache")
try:
if os.path.exists(cachePath):
with open(cachePath, "rb") as cacheFile:
gallery.exifCache = pickle.load(cacheFi... | [
"Restores",
"the",
"exif",
"data",
"cache",
"from",
"the",
"cache",
"file"
] | saimn/sigal | python | https://github.com/saimn/sigal/blob/912ca39991355d358dc85fd55c7aeabdd7acc386/sigal/plugins/extended_caching.py#L53-L65 | [
"def",
"_restore_cache",
"(",
"gallery",
")",
":",
"cachePath",
"=",
"os",
".",
"path",
".",
"join",
"(",
"gallery",
".",
"settings",
"[",
"\"destination\"",
"]",
",",
"\".exif_cache\"",
")",
"try",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"ca... | 912ca39991355d358dc85fd55c7aeabdd7acc386 |
valid | save_cache | Stores the exif data of all images in the gallery | sigal/plugins/extended_caching.py | def save_cache(gallery):
"""Stores the exif data of all images in the gallery"""
if hasattr(gallery, "exifCache"):
cache = gallery.exifCache
else:
cache = gallery.exifCache = {}
for album in gallery.albums.values():
for image in album.images:
cache[os.path.join(imag... | def save_cache(gallery):
"""Stores the exif data of all images in the gallery"""
if hasattr(gallery, "exifCache"):
cache = gallery.exifCache
else:
cache = gallery.exifCache = {}
for album in gallery.albums.values():
for image in album.images:
cache[os.path.join(imag... | [
"Stores",
"the",
"exif",
"data",
"of",
"all",
"images",
"in",
"the",
"gallery"
] | saimn/sigal | python | https://github.com/saimn/sigal/blob/912ca39991355d358dc85fd55c7aeabdd7acc386/sigal/plugins/extended_caching.py#L68-L93 | [
"def",
"save_cache",
"(",
"gallery",
")",
":",
"if",
"hasattr",
"(",
"gallery",
",",
"\"exifCache\"",
")",
":",
"cache",
"=",
"gallery",
".",
"exifCache",
"else",
":",
"cache",
"=",
"gallery",
".",
"exifCache",
"=",
"{",
"}",
"for",
"album",
"in",
"gal... | 912ca39991355d358dc85fd55c7aeabdd7acc386 |
valid | filter_nomedia | Removes all filtered Media and subdirs from an Album | sigal/plugins/nomedia.py | def filter_nomedia(album, settings=None):
"""Removes all filtered Media and subdirs from an Album"""
nomediapath = os.path.join(album.src_path, ".nomedia")
if os.path.isfile(nomediapath):
if os.path.getsize(nomediapath) == 0:
logger.info("Ignoring album '%s' because of present 0-byte "
... | def filter_nomedia(album, settings=None):
"""Removes all filtered Media and subdirs from an Album"""
nomediapath = os.path.join(album.src_path, ".nomedia")
if os.path.isfile(nomediapath):
if os.path.getsize(nomediapath) == 0:
logger.info("Ignoring album '%s' because of present 0-byte "
... | [
"Removes",
"all",
"filtered",
"Media",
"and",
"subdirs",
"from",
"an",
"Album"
] | saimn/sigal | python | https://github.com/saimn/sigal/blob/912ca39991355d358dc85fd55c7aeabdd7acc386/sigal/plugins/nomedia.py#L82-L120 | [
"def",
"filter_nomedia",
"(",
"album",
",",
"settings",
"=",
"None",
")",
":",
"nomediapath",
"=",
"os",
".",
"path",
".",
"join",
"(",
"album",
".",
"src_path",
",",
"\".nomedia\"",
")",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"nomediapath",
")",... | 912ca39991355d358dc85fd55c7aeabdd7acc386 |
valid | init | Copy a sample config file in the current directory (default to
'sigal.conf.py'), or use the provided 'path'. | sigal/__init__.py | def init(path):
"""Copy a sample config file in the current directory (default to
'sigal.conf.py'), or use the provided 'path'."""
if os.path.isfile(path):
print("Found an existing config file, will abort to keep it safe.")
sys.exit(1)
from pkg_resources import resource_string
conf... | def init(path):
"""Copy a sample config file in the current directory (default to
'sigal.conf.py'), or use the provided 'path'."""
if os.path.isfile(path):
print("Found an existing config file, will abort to keep it safe.")
sys.exit(1)
from pkg_resources import resource_string
conf... | [
"Copy",
"a",
"sample",
"config",
"file",
"in",
"the",
"current",
"directory",
"(",
"default",
"to",
"sigal",
".",
"conf",
".",
"py",
")",
"or",
"use",
"the",
"provided",
"path",
"."
] | saimn/sigal | python | https://github.com/saimn/sigal/blob/912ca39991355d358dc85fd55c7aeabdd7acc386/sigal/__init__.py#L67-L80 | [
"def",
"init",
"(",
"path",
")",
":",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"path",
")",
":",
"print",
"(",
"\"Found an existing config file, will abort to keep it safe.\"",
")",
"sys",
".",
"exit",
"(",
"1",
")",
"from",
"pkg_resources",
"import",
"r... | 912ca39991355d358dc85fd55c7aeabdd7acc386 |
valid | build | Run sigal to process a directory.
If provided, 'source', 'destination' and 'theme' will override the
corresponding values from the settings file. | sigal/__init__.py | def build(source, destination, debug, verbose, force, config, theme, title,
ncpu):
"""Run sigal to process a directory.
If provided, 'source', 'destination' and 'theme' will override the
corresponding values from the settings file.
"""
level = ((debug and logging.DEBUG) or (verbose and l... | def build(source, destination, debug, verbose, force, config, theme, title,
ncpu):
"""Run sigal to process a directory.
If provided, 'source', 'destination' and 'theme' will override the
corresponding values from the settings file.
"""
level = ((debug and logging.DEBUG) or (verbose and l... | [
"Run",
"sigal",
"to",
"process",
"a",
"directory",
"."
] | saimn/sigal | python | https://github.com/saimn/sigal/blob/912ca39991355d358dc85fd55c7aeabdd7acc386/sigal/__init__.py#L97-L169 | [
"def",
"build",
"(",
"source",
",",
"destination",
",",
"debug",
",",
"verbose",
",",
"force",
",",
"config",
",",
"theme",
",",
"title",
",",
"ncpu",
")",
":",
"level",
"=",
"(",
"(",
"debug",
"and",
"logging",
".",
"DEBUG",
")",
"or",
"(",
"verbo... | 912ca39991355d358dc85fd55c7aeabdd7acc386 |
valid | init_plugins | Load plugins and call register(). | sigal/__init__.py | def init_plugins(settings):
"""Load plugins and call register()."""
logger = logging.getLogger(__name__)
logger.debug('Plugin paths: %s', settings['plugin_paths'])
for path in settings['plugin_paths']:
sys.path.insert(0, path)
for plugin in settings['plugins']:
try:
if... | def init_plugins(settings):
"""Load plugins and call register()."""
logger = logging.getLogger(__name__)
logger.debug('Plugin paths: %s', settings['plugin_paths'])
for path in settings['plugin_paths']:
sys.path.insert(0, path)
for plugin in settings['plugins']:
try:
if... | [
"Load",
"plugins",
"and",
"call",
"register",
"()",
"."
] | saimn/sigal | python | https://github.com/saimn/sigal/blob/912ca39991355d358dc85fd55c7aeabdd7acc386/sigal/__init__.py#L172-L193 | [
"def",
"init_plugins",
"(",
"settings",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"logger",
".",
"debug",
"(",
"'Plugin paths: %s'",
",",
"settings",
"[",
"'plugin_paths'",
"]",
")",
"for",
"path",
"in",
"settings",
"[",
"... | 912ca39991355d358dc85fd55c7aeabdd7acc386 |
valid | serve | Run a simple web server. | sigal/__init__.py | def serve(destination, port, config):
"""Run a simple web server."""
if os.path.exists(destination):
pass
elif os.path.exists(config):
settings = read_settings(config)
destination = settings.get('destination')
if not os.path.exists(destination):
sys.stderr.write("... | def serve(destination, port, config):
"""Run a simple web server."""
if os.path.exists(destination):
pass
elif os.path.exists(config):
settings = read_settings(config)
destination = settings.get('destination')
if not os.path.exists(destination):
sys.stderr.write("... | [
"Run",
"a",
"simple",
"web",
"server",
"."
] | saimn/sigal | python | https://github.com/saimn/sigal/blob/912ca39991355d358dc85fd55c7aeabdd7acc386/sigal/__init__.py#L201-L230 | [
"def",
"serve",
"(",
"destination",
",",
"port",
",",
"config",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"destination",
")",
":",
"pass",
"elif",
"os",
".",
"path",
".",
"exists",
"(",
"config",
")",
":",
"settings",
"=",
"read_settings... | 912ca39991355d358dc85fd55c7aeabdd7acc386 |
valid | set_meta | Write metadata keys to .md file.
TARGET can be a media file or an album directory. KEYS are key/value pairs.
Ex, to set the title of test.jpg to "My test image":
sigal set_meta test.jpg title "My test image" | sigal/__init__.py | def set_meta(target, keys, overwrite=False):
"""Write metadata keys to .md file.
TARGET can be a media file or an album directory. KEYS are key/value pairs.
Ex, to set the title of test.jpg to "My test image":
sigal set_meta test.jpg title "My test image"
"""
if not os.path.exists(target):
... | def set_meta(target, keys, overwrite=False):
"""Write metadata keys to .md file.
TARGET can be a media file or an album directory. KEYS are key/value pairs.
Ex, to set the title of test.jpg to "My test image":
sigal set_meta test.jpg title "My test image"
"""
if not os.path.exists(target):
... | [
"Write",
"metadata",
"keys",
"to",
".",
"md",
"file",
"."
] | saimn/sigal | python | https://github.com/saimn/sigal/blob/912ca39991355d358dc85fd55c7aeabdd7acc386/sigal/__init__.py#L238-L268 | [
"def",
"set_meta",
"(",
"target",
",",
"keys",
",",
"overwrite",
"=",
"False",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"target",
")",
":",
"sys",
".",
"stderr",
".",
"write",
"(",
"\"The target {} does not exist.\\n\"",
".",
"format... | 912ca39991355d358dc85fd55c7aeabdd7acc386 |
valid | generate_image | Image processor, rotate and resize the image.
:param source: path to an image
:param outname: output filename
:param settings: settings dict
:param options: dict with PIL options (quality, optimize, progressive) | sigal/image.py | def generate_image(source, outname, settings, options=None):
"""Image processor, rotate and resize the image.
:param source: path to an image
:param outname: output filename
:param settings: settings dict
:param options: dict with PIL options (quality, optimize, progressive)
"""
logger = ... | def generate_image(source, outname, settings, options=None):
"""Image processor, rotate and resize the image.
:param source: path to an image
:param outname: output filename
:param settings: settings dict
:param options: dict with PIL options (quality, optimize, progressive)
"""
logger = ... | [
"Image",
"processor",
"rotate",
"and",
"resize",
"the",
"image",
"."
] | saimn/sigal | python | https://github.com/saimn/sigal/blob/912ca39991355d358dc85fd55c7aeabdd7acc386/sigal/image.py#L72-L137 | [
"def",
"generate_image",
"(",
"source",
",",
"outname",
",",
"settings",
",",
"options",
"=",
"None",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"if",
"settings",
"[",
"'use_orig'",
"]",
"or",
"source",
".",
"endswith",
"... | 912ca39991355d358dc85fd55c7aeabdd7acc386 |
valid | generate_thumbnail | Create a thumbnail image. | sigal/image.py | def generate_thumbnail(source, outname, box, fit=True, options=None,
thumb_fit_centering=(0.5, 0.5)):
"""Create a thumbnail image."""
logger = logging.getLogger(__name__)
img = _read_image(source)
original_format = img.format
if fit:
img = ImageOps.fit(img, box, PILI... | def generate_thumbnail(source, outname, box, fit=True, options=None,
thumb_fit_centering=(0.5, 0.5)):
"""Create a thumbnail image."""
logger = logging.getLogger(__name__)
img = _read_image(source)
original_format = img.format
if fit:
img = ImageOps.fit(img, box, PILI... | [
"Create",
"a",
"thumbnail",
"image",
"."
] | saimn/sigal | python | https://github.com/saimn/sigal/blob/912ca39991355d358dc85fd55c7aeabdd7acc386/sigal/image.py#L140-L156 | [
"def",
"generate_thumbnail",
"(",
"source",
",",
"outname",
",",
"box",
",",
"fit",
"=",
"True",
",",
"options",
"=",
"None",
",",
"thumb_fit_centering",
"=",
"(",
"0.5",
",",
"0.5",
")",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"__na... | 912ca39991355d358dc85fd55c7aeabdd7acc386 |
valid | process_image | Process one image: resize, create thumbnail. | sigal/image.py | def process_image(filepath, outpath, settings):
"""Process one image: resize, create thumbnail."""
logger = logging.getLogger(__name__)
logger.info('Processing %s', filepath)
filename = os.path.split(filepath)[1]
outname = os.path.join(outpath, filename)
ext = os.path.splitext(filename)[1]
... | def process_image(filepath, outpath, settings):
"""Process one image: resize, create thumbnail."""
logger = logging.getLogger(__name__)
logger.info('Processing %s', filepath)
filename = os.path.split(filepath)[1]
outname = os.path.join(outpath, filename)
ext = os.path.splitext(filename)[1]
... | [
"Process",
"one",
"image",
":",
"resize",
"create",
"thumbnail",
"."
] | saimn/sigal | python | https://github.com/saimn/sigal/blob/912ca39991355d358dc85fd55c7aeabdd7acc386/sigal/image.py#L159-L191 | [
"def",
"process_image",
"(",
"filepath",
",",
"outpath",
",",
"settings",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"logger",
".",
"info",
"(",
"'Processing %s'",
",",
"filepath",
")",
"filename",
"=",
"os",
".",
"path",
... | 912ca39991355d358dc85fd55c7aeabdd7acc386 |
valid | get_size | Return image size (width and height). | sigal/image.py | def get_size(file_path):
"""Return image size (width and height)."""
try:
im = _read_image(file_path)
except (IOError, IndexError, TypeError, AttributeError) as e:
logger = logging.getLogger(__name__)
logger.error("Could not read size of %s due to %r", file_path, e)
else:
... | def get_size(file_path):
"""Return image size (width and height)."""
try:
im = _read_image(file_path)
except (IOError, IndexError, TypeError, AttributeError) as e:
logger = logging.getLogger(__name__)
logger.error("Could not read size of %s due to %r", file_path, e)
else:
... | [
"Return",
"image",
"size",
"(",
"width",
"and",
"height",
")",
"."
] | saimn/sigal | python | https://github.com/saimn/sigal/blob/912ca39991355d358dc85fd55c7aeabdd7acc386/sigal/image.py#L194-L206 | [
"def",
"get_size",
"(",
"file_path",
")",
":",
"try",
":",
"im",
"=",
"_read_image",
"(",
"file_path",
")",
"except",
"(",
"IOError",
",",
"IndexError",
",",
"TypeError",
",",
"AttributeError",
")",
"as",
"e",
":",
"logger",
"=",
"logging",
".",
"getLogg... | 912ca39991355d358dc85fd55c7aeabdd7acc386 |
valid | get_exif_data | Return a dict with the raw EXIF data. | sigal/image.py | def get_exif_data(filename):
"""Return a dict with the raw EXIF data."""
logger = logging.getLogger(__name__)
img = _read_image(filename)
try:
exif = img._getexif() or {}
except ZeroDivisionError:
logger.warning('Failed to read EXIF data.')
return None
data = {TAGS.ge... | def get_exif_data(filename):
"""Return a dict with the raw EXIF data."""
logger = logging.getLogger(__name__)
img = _read_image(filename)
try:
exif = img._getexif() or {}
except ZeroDivisionError:
logger.warning('Failed to read EXIF data.')
return None
data = {TAGS.ge... | [
"Return",
"a",
"dict",
"with",
"the",
"raw",
"EXIF",
"data",
"."
] | saimn/sigal | python | https://github.com/saimn/sigal/blob/912ca39991355d358dc85fd55c7aeabdd7acc386/sigal/image.py#L209-L232 | [
"def",
"get_exif_data",
"(",
"filename",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"img",
"=",
"_read_image",
"(",
"filename",
")",
"try",
":",
"exif",
"=",
"img",
".",
"_getexif",
"(",
")",
"or",
"{",
"}",
"except",
... | 912ca39991355d358dc85fd55c7aeabdd7acc386 |
valid | get_iptc_data | Return a dict with the raw IPTC data. | sigal/image.py | def get_iptc_data(filename):
"""Return a dict with the raw IPTC data."""
logger = logging.getLogger(__name__)
iptc_data = {}
raw_iptc = {}
# PILs IptcImagePlugin issues a SyntaxError in certain circumstances
# with malformed metadata, see PIL/IptcImagePlugin.py", line 71.
# ( https://gith... | def get_iptc_data(filename):
"""Return a dict with the raw IPTC data."""
logger = logging.getLogger(__name__)
iptc_data = {}
raw_iptc = {}
# PILs IptcImagePlugin issues a SyntaxError in certain circumstances
# with malformed metadata, see PIL/IptcImagePlugin.py", line 71.
# ( https://gith... | [
"Return",
"a",
"dict",
"with",
"the",
"raw",
"IPTC",
"data",
"."
] | saimn/sigal | python | https://github.com/saimn/sigal/blob/912ca39991355d358dc85fd55c7aeabdd7acc386/sigal/image.py#L235-L268 | [
"def",
"get_iptc_data",
"(",
"filename",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"iptc_data",
"=",
"{",
"}",
"raw_iptc",
"=",
"{",
"}",
"# PILs IptcImagePlugin issues a SyntaxError in certain circumstances",
"# with malformed metadata... | 912ca39991355d358dc85fd55c7aeabdd7acc386 |
valid | dms_to_degrees | Convert degree/minute/second to decimal degrees. | sigal/image.py | def dms_to_degrees(v):
"""Convert degree/minute/second to decimal degrees."""
d = float(v[0][0]) / float(v[0][1])
m = float(v[1][0]) / float(v[1][1])
s = float(v[2][0]) / float(v[2][1])
return d + (m / 60.0) + (s / 3600.0) | def dms_to_degrees(v):
"""Convert degree/minute/second to decimal degrees."""
d = float(v[0][0]) / float(v[0][1])
m = float(v[1][0]) / float(v[1][1])
s = float(v[2][0]) / float(v[2][1])
return d + (m / 60.0) + (s / 3600.0) | [
"Convert",
"degree",
"/",
"minute",
"/",
"second",
"to",
"decimal",
"degrees",
"."
] | saimn/sigal | python | https://github.com/saimn/sigal/blob/912ca39991355d358dc85fd55c7aeabdd7acc386/sigal/image.py#L271-L277 | [
"def",
"dms_to_degrees",
"(",
"v",
")",
":",
"d",
"=",
"float",
"(",
"v",
"[",
"0",
"]",
"[",
"0",
"]",
")",
"/",
"float",
"(",
"v",
"[",
"0",
"]",
"[",
"1",
"]",
")",
"m",
"=",
"float",
"(",
"v",
"[",
"1",
"]",
"[",
"0",
"]",
")",
"/... | 912ca39991355d358dc85fd55c7aeabdd7acc386 |
valid | get_exif_tags | Make a simplified version with common tags from raw EXIF data. | sigal/image.py | def get_exif_tags(data, datetime_format='%c'):
"""Make a simplified version with common tags from raw EXIF data."""
logger = logging.getLogger(__name__)
simple = {}
for tag in ('Model', 'Make', 'LensModel'):
if tag in data:
if isinstance(data[tag], tuple):
simple[ta... | def get_exif_tags(data, datetime_format='%c'):
"""Make a simplified version with common tags from raw EXIF data."""
logger = logging.getLogger(__name__)
simple = {}
for tag in ('Model', 'Make', 'LensModel'):
if tag in data:
if isinstance(data[tag], tuple):
simple[ta... | [
"Make",
"a",
"simplified",
"version",
"with",
"common",
"tags",
"from",
"raw",
"EXIF",
"data",
"."
] | saimn/sigal | python | https://github.com/saimn/sigal/blob/912ca39991355d358dc85fd55c7aeabdd7acc386/sigal/image.py#L280-L353 | [
"def",
"get_exif_tags",
"(",
"data",
",",
"datetime_format",
"=",
"'%c'",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"simple",
"=",
"{",
"}",
"for",
"tag",
"in",
"(",
"'Model'",
",",
"'Make'",
",",
"'LensModel'",
")",
"... | 912ca39991355d358dc85fd55c7aeabdd7acc386 |
valid | Media.big | Path to the original image, if ``keep_orig`` is set (relative to the
album directory). Copy the file if needed. | sigal/gallery.py | def big(self):
"""Path to the original image, if ``keep_orig`` is set (relative to the
album directory). Copy the file if needed.
"""
if self.settings['keep_orig']:
s = self.settings
if s['use_orig']:
# The image *is* the original, just use it
... | def big(self):
"""Path to the original image, if ``keep_orig`` is set (relative to the
album directory). Copy the file if needed.
"""
if self.settings['keep_orig']:
s = self.settings
if s['use_orig']:
# The image *is* the original, just use it
... | [
"Path",
"to",
"the",
"original",
"image",
"if",
"keep_orig",
"is",
"set",
"(",
"relative",
"to",
"the",
"album",
"directory",
")",
".",
"Copy",
"the",
"file",
"if",
"needed",
"."
] | saimn/sigal | python | https://github.com/saimn/sigal/blob/912ca39991355d358dc85fd55c7aeabdd7acc386/sigal/gallery.py#L103-L118 | [
"def",
"big",
"(",
"self",
")",
":",
"if",
"self",
".",
"settings",
"[",
"'keep_orig'",
"]",
":",
"s",
"=",
"self",
".",
"settings",
"if",
"s",
"[",
"'use_orig'",
"]",
":",
"# The image *is* the original, just use it",
"return",
"self",
".",
"filename",
"o... | 912ca39991355d358dc85fd55c7aeabdd7acc386 |
valid | Media.thumbnail | Path to the thumbnail image (relative to the album directory). | sigal/gallery.py | def thumbnail(self):
"""Path to the thumbnail image (relative to the album directory)."""
if not isfile(self.thumb_path):
self.logger.debug('Generating thumbnail for %r', self)
path = (self.dst_path if os.path.exists(self.dst_path)
else self.src_path)
... | def thumbnail(self):
"""Path to the thumbnail image (relative to the album directory)."""
if not isfile(self.thumb_path):
self.logger.debug('Generating thumbnail for %r', self)
path = (self.dst_path if os.path.exists(self.dst_path)
else self.src_path)
... | [
"Path",
"to",
"the",
"thumbnail",
"image",
"(",
"relative",
"to",
"the",
"album",
"directory",
")",
"."
] | saimn/sigal | python | https://github.com/saimn/sigal/blob/912ca39991355d358dc85fd55c7aeabdd7acc386/sigal/gallery.py#L127-L149 | [
"def",
"thumbnail",
"(",
"self",
")",
":",
"if",
"not",
"isfile",
"(",
"self",
".",
"thumb_path",
")",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"'Generating thumbnail for %r'",
",",
"self",
")",
"path",
"=",
"(",
"self",
".",
"dst_path",
"if",
"o... | 912ca39991355d358dc85fd55c7aeabdd7acc386 |
valid | Media._get_metadata | Get image metadata from filename.md: title, description, meta. | sigal/gallery.py | def _get_metadata(self):
""" Get image metadata from filename.md: title, description, meta."""
self.description = ''
self.meta = {}
self.title = ''
descfile = splitext(self.src_path)[0] + '.md'
if isfile(descfile):
meta = read_markdown(descfile)
f... | def _get_metadata(self):
""" Get image metadata from filename.md: title, description, meta."""
self.description = ''
self.meta = {}
self.title = ''
descfile = splitext(self.src_path)[0] + '.md'
if isfile(descfile):
meta = read_markdown(descfile)
f... | [
"Get",
"image",
"metadata",
"from",
"filename",
".",
"md",
":",
"title",
"description",
"meta",
"."
] | saimn/sigal | python | https://github.com/saimn/sigal/blob/912ca39991355d358dc85fd55c7aeabdd7acc386/sigal/gallery.py#L151-L161 | [
"def",
"_get_metadata",
"(",
"self",
")",
":",
"self",
".",
"description",
"=",
"''",
"self",
".",
"meta",
"=",
"{",
"}",
"self",
".",
"title",
"=",
"''",
"descfile",
"=",
"splitext",
"(",
"self",
".",
"src_path",
")",
"[",
"0",
"]",
"+",
"'.md'",
... | 912ca39991355d358dc85fd55c7aeabdd7acc386 |
valid | Album._get_metadata | Get album metadata from `description_file` (`index.md`):
-> title, thumbnail image, description | sigal/gallery.py | def _get_metadata(self):
"""Get album metadata from `description_file` (`index.md`):
-> title, thumbnail image, description
"""
descfile = join(self.src_path, self.description_file)
self.description = ''
self.meta = {}
# default: get title from directory name
... | def _get_metadata(self):
"""Get album metadata from `description_file` (`index.md`):
-> title, thumbnail image, description
"""
descfile = join(self.src_path, self.description_file)
self.description = ''
self.meta = {}
# default: get title from directory name
... | [
"Get",
"album",
"metadata",
"from",
"description_file",
"(",
"index",
".",
"md",
")",
":"
] | saimn/sigal | python | https://github.com/saimn/sigal/blob/912ca39991355d358dc85fd55c7aeabdd7acc386/sigal/gallery.py#L322-L343 | [
"def",
"_get_metadata",
"(",
"self",
")",
":",
"descfile",
"=",
"join",
"(",
"self",
".",
"src_path",
",",
"self",
".",
"description_file",
")",
"self",
".",
"description",
"=",
"''",
"self",
".",
"meta",
"=",
"{",
"}",
"# default: get title from directory n... | 912ca39991355d358dc85fd55c7aeabdd7acc386 |
valid | Album.create_output_directories | Create output directories for thumbnails and original images. | sigal/gallery.py | def create_output_directories(self):
"""Create output directories for thumbnails and original images."""
check_or_create_dir(self.dst_path)
if self.medias:
check_or_create_dir(join(self.dst_path,
self.settings['thumb_dir']))
if self.medi... | def create_output_directories(self):
"""Create output directories for thumbnails and original images."""
check_or_create_dir(self.dst_path)
if self.medias:
check_or_create_dir(join(self.dst_path,
self.settings['thumb_dir']))
if self.medi... | [
"Create",
"output",
"directories",
"for",
"thumbnails",
"and",
"original",
"images",
"."
] | saimn/sigal | python | https://github.com/saimn/sigal/blob/912ca39991355d358dc85fd55c7aeabdd7acc386/sigal/gallery.py#L345-L355 | [
"def",
"create_output_directories",
"(",
"self",
")",
":",
"check_or_create_dir",
"(",
"self",
".",
"dst_path",
")",
"if",
"self",
".",
"medias",
":",
"check_or_create_dir",
"(",
"join",
"(",
"self",
".",
"dst_path",
",",
"self",
".",
"settings",
"[",
"'thum... | 912ca39991355d358dc85fd55c7aeabdd7acc386 |
valid | Album.albums | List of :class:`~sigal.gallery.Album` objects for each
sub-directory. | sigal/gallery.py | def albums(self):
"""List of :class:`~sigal.gallery.Album` objects for each
sub-directory.
"""
root_path = self.path if self.path != '.' else ''
return [self.gallery.albums[join(root_path, path)]
for path in self.subdirs] | def albums(self):
"""List of :class:`~sigal.gallery.Album` objects for each
sub-directory.
"""
root_path = self.path if self.path != '.' else ''
return [self.gallery.albums[join(root_path, path)]
for path in self.subdirs] | [
"List",
"of",
":",
"class",
":",
"~sigal",
".",
"gallery",
".",
"Album",
"objects",
"for",
"each",
"sub",
"-",
"directory",
"."
] | saimn/sigal | python | https://github.com/saimn/sigal/blob/912ca39991355d358dc85fd55c7aeabdd7acc386/sigal/gallery.py#L407-L413 | [
"def",
"albums",
"(",
"self",
")",
":",
"root_path",
"=",
"self",
".",
"path",
"if",
"self",
".",
"path",
"!=",
"'.'",
"else",
"''",
"return",
"[",
"self",
".",
"gallery",
".",
"albums",
"[",
"join",
"(",
"root_path",
",",
"path",
")",
"]",
"for",
... | 912ca39991355d358dc85fd55c7aeabdd7acc386 |
valid | Album.url | URL of the album, relative to its parent. | sigal/gallery.py | def url(self):
"""URL of the album, relative to its parent."""
url = self.name.encode('utf-8')
return url_quote(url) + '/' + self.url_ext | def url(self):
"""URL of the album, relative to its parent."""
url = self.name.encode('utf-8')
return url_quote(url) + '/' + self.url_ext | [
"URL",
"of",
"the",
"album",
"relative",
"to",
"its",
"parent",
"."
] | saimn/sigal | python | https://github.com/saimn/sigal/blob/912ca39991355d358dc85fd55c7aeabdd7acc386/sigal/gallery.py#L416-L419 | [
"def",
"url",
"(",
"self",
")",
":",
"url",
"=",
"self",
".",
"name",
".",
"encode",
"(",
"'utf-8'",
")",
"return",
"url_quote",
"(",
"url",
")",
"+",
"'/'",
"+",
"self",
".",
"url_ext"
] | 912ca39991355d358dc85fd55c7aeabdd7acc386 |
valid | Album.thumbnail | Path to the thumbnail of the album. | sigal/gallery.py | def thumbnail(self):
"""Path to the thumbnail of the album."""
if self._thumbnail:
# stop if it is already set
return self._thumbnail
# Test the thumbnail from the Markdown file.
thumbnail = self.meta.get('thumbnail', [''])[0]
if thumbnail and isfile(jo... | def thumbnail(self):
"""Path to the thumbnail of the album."""
if self._thumbnail:
# stop if it is already set
return self._thumbnail
# Test the thumbnail from the Markdown file.
thumbnail = self.meta.get('thumbnail', [''])[0]
if thumbnail and isfile(jo... | [
"Path",
"to",
"the",
"thumbnail",
"of",
"the",
"album",
"."
] | saimn/sigal | python | https://github.com/saimn/sigal/blob/912ca39991355d358dc85fd55c7aeabdd7acc386/sigal/gallery.py#L422-L483 | [
"def",
"thumbnail",
"(",
"self",
")",
":",
"if",
"self",
".",
"_thumbnail",
":",
"# stop if it is already set",
"return",
"self",
".",
"_thumbnail",
"# Test the thumbnail from the Markdown file.",
"thumbnail",
"=",
"self",
".",
"meta",
".",
"get",
"(",
"'thumbnail'"... | 912ca39991355d358dc85fd55c7aeabdd7acc386 |
valid | Album.breadcrumb | List of ``(url, title)`` tuples defining the current breadcrumb
path. | sigal/gallery.py | def breadcrumb(self):
"""List of ``(url, title)`` tuples defining the current breadcrumb
path.
"""
if self.path == '.':
return []
path = self.path
breadcrumb = [((self.url_ext or '.'), self.title)]
while True:
path = os.path.normpath(os.p... | def breadcrumb(self):
"""List of ``(url, title)`` tuples defining the current breadcrumb
path.
"""
if self.path == '.':
return []
path = self.path
breadcrumb = [((self.url_ext or '.'), self.title)]
while True:
path = os.path.normpath(os.p... | [
"List",
"of",
"(",
"url",
"title",
")",
"tuples",
"defining",
"the",
"current",
"breadcrumb",
"path",
"."
] | saimn/sigal | python | https://github.com/saimn/sigal/blob/912ca39991355d358dc85fd55c7aeabdd7acc386/sigal/gallery.py#L494-L514 | [
"def",
"breadcrumb",
"(",
"self",
")",
":",
"if",
"self",
".",
"path",
"==",
"'.'",
":",
"return",
"[",
"]",
"path",
"=",
"self",
".",
"path",
"breadcrumb",
"=",
"[",
"(",
"(",
"self",
".",
"url_ext",
"or",
"'.'",
")",
",",
"self",
".",
"title",
... | 912ca39991355d358dc85fd55c7aeabdd7acc386 |
valid | Album.zip | Make a ZIP archive with all media files and return its path.
If the ``zip_gallery`` setting is set,it contains the location of a zip
archive with all original images of the corresponding directory. | sigal/gallery.py | def zip(self):
"""Make a ZIP archive with all media files and return its path.
If the ``zip_gallery`` setting is set,it contains the location of a zip
archive with all original images of the corresponding directory.
"""
zip_gallery = self.settings['zip_gallery']
if zip... | def zip(self):
"""Make a ZIP archive with all media files and return its path.
If the ``zip_gallery`` setting is set,it contains the location of a zip
archive with all original images of the corresponding directory.
"""
zip_gallery = self.settings['zip_gallery']
if zip... | [
"Make",
"a",
"ZIP",
"archive",
"with",
"all",
"media",
"files",
"and",
"return",
"its",
"path",
"."
] | saimn/sigal | python | https://github.com/saimn/sigal/blob/912ca39991355d358dc85fd55c7aeabdd7acc386/sigal/gallery.py#L523-L554 | [
"def",
"zip",
"(",
"self",
")",
":",
"zip_gallery",
"=",
"self",
".",
"settings",
"[",
"'zip_gallery'",
"]",
"if",
"zip_gallery",
"and",
"len",
"(",
"self",
")",
">",
"0",
":",
"zip_gallery",
"=",
"zip_gallery",
".",
"format",
"(",
"album",
"=",
"self"... | 912ca39991355d358dc85fd55c7aeabdd7acc386 |
valid | Gallery.get_albums | Return the list of all sub-directories of path. | sigal/gallery.py | def get_albums(self, path):
"""Return the list of all sub-directories of path."""
for name in self.albums[path].subdirs:
subdir = os.path.normpath(join(path, name))
yield subdir, self.albums[subdir]
for subname, album in self.get_albums(subdir):
yield... | def get_albums(self, path):
"""Return the list of all sub-directories of path."""
for name in self.albums[path].subdirs:
subdir = os.path.normpath(join(path, name))
yield subdir, self.albums[subdir]
for subname, album in self.get_albums(subdir):
yield... | [
"Return",
"the",
"list",
"of",
"all",
"sub",
"-",
"directories",
"of",
"path",
"."
] | saimn/sigal | python | https://github.com/saimn/sigal/blob/912ca39991355d358dc85fd55c7aeabdd7acc386/sigal/gallery.py#L657-L664 | [
"def",
"get_albums",
"(",
"self",
",",
"path",
")",
":",
"for",
"name",
"in",
"self",
".",
"albums",
"[",
"path",
"]",
".",
"subdirs",
":",
"subdir",
"=",
"os",
".",
"path",
".",
"normpath",
"(",
"join",
"(",
"path",
",",
"name",
")",
")",
"yield... | 912ca39991355d358dc85fd55c7aeabdd7acc386 |
valid | Gallery.build | Create the image gallery | sigal/gallery.py | def build(self, force=False):
"Create the image gallery"
if not self.albums:
self.logger.warning("No albums found.")
return
def log_func(x):
# 63 is the total length of progressbar, label, percentage, etc
available_length = get_terminal_size()[0]... | def build(self, force=False):
"Create the image gallery"
if not self.albums:
self.logger.warning("No albums found.")
return
def log_func(x):
# 63 is the total length of progressbar, label, percentage, etc
available_length = get_terminal_size()[0]... | [
"Create",
"the",
"image",
"gallery"
] | saimn/sigal | python | https://github.com/saimn/sigal/blob/912ca39991355d358dc85fd55c7aeabdd7acc386/sigal/gallery.py#L666-L747 | [
"def",
"build",
"(",
"self",
",",
"force",
"=",
"False",
")",
":",
"if",
"not",
"self",
".",
"albums",
":",
"self",
".",
"logger",
".",
"warning",
"(",
"\"No albums found.\"",
")",
"return",
"def",
"log_func",
"(",
"x",
")",
":",
"# 63 is the total lengt... | 912ca39991355d358dc85fd55c7aeabdd7acc386 |
valid | Gallery.process_dir | Process a list of images in a directory. | sigal/gallery.py | def process_dir(self, album, force=False):
"""Process a list of images in a directory."""
for f in album:
if isfile(f.dst_path) and not force:
self.logger.info("%s exists - skipping", f.filename)
self.stats[f.type + '_skipped'] += 1
else:
... | def process_dir(self, album, force=False):
"""Process a list of images in a directory."""
for f in album:
if isfile(f.dst_path) and not force:
self.logger.info("%s exists - skipping", f.filename)
self.stats[f.type + '_skipped'] += 1
else:
... | [
"Process",
"a",
"list",
"of",
"images",
"in",
"a",
"directory",
"."
] | saimn/sigal | python | https://github.com/saimn/sigal/blob/912ca39991355d358dc85fd55c7aeabdd7acc386/sigal/gallery.py#L762-L771 | [
"def",
"process_dir",
"(",
"self",
",",
"album",
",",
"force",
"=",
"False",
")",
":",
"for",
"f",
"in",
"album",
":",
"if",
"isfile",
"(",
"f",
".",
"dst_path",
")",
"and",
"not",
"force",
":",
"self",
".",
"logger",
".",
"info",
"(",
"\"%s exists... | 912ca39991355d358dc85fd55c7aeabdd7acc386 |
valid | reduce_opacity | Returns an image with reduced opacity. | sigal/plugins/watermark.py | def reduce_opacity(im, opacity):
"""Returns an image with reduced opacity."""
assert opacity >= 0 and opacity <= 1
if im.mode != 'RGBA':
im = im.convert('RGBA')
else:
im = im.copy()
alpha = im.split()[3]
alpha = ImageEnhance.Brightness(alpha).enhance(opacity)
im.putalpha(alph... | def reduce_opacity(im, opacity):
"""Returns an image with reduced opacity."""
assert opacity >= 0 and opacity <= 1
if im.mode != 'RGBA':
im = im.convert('RGBA')
else:
im = im.copy()
alpha = im.split()[3]
alpha = ImageEnhance.Brightness(alpha).enhance(opacity)
im.putalpha(alph... | [
"Returns",
"an",
"image",
"with",
"reduced",
"opacity",
"."
] | saimn/sigal | python | https://github.com/saimn/sigal/blob/912ca39991355d358dc85fd55c7aeabdd7acc386/sigal/plugins/watermark.py#L42-L52 | [
"def",
"reduce_opacity",
"(",
"im",
",",
"opacity",
")",
":",
"assert",
"opacity",
">=",
"0",
"and",
"opacity",
"<=",
"1",
"if",
"im",
".",
"mode",
"!=",
"'RGBA'",
":",
"im",
"=",
"im",
".",
"convert",
"(",
"'RGBA'",
")",
"else",
":",
"im",
"=",
... | 912ca39991355d358dc85fd55c7aeabdd7acc386 |
valid | watermark | Adds a watermark to an image. | sigal/plugins/watermark.py | def watermark(im, mark, position, opacity=1):
"""Adds a watermark to an image."""
if opacity < 1:
mark = reduce_opacity(mark, opacity)
if im.mode != 'RGBA':
im = im.convert('RGBA')
# create a transparent layer the size of the image and draw the
# watermark in that layer.
layer = ... | def watermark(im, mark, position, opacity=1):
"""Adds a watermark to an image."""
if opacity < 1:
mark = reduce_opacity(mark, opacity)
if im.mode != 'RGBA':
im = im.convert('RGBA')
# create a transparent layer the size of the image and draw the
# watermark in that layer.
layer = ... | [
"Adds",
"a",
"watermark",
"to",
"an",
"image",
"."
] | saimn/sigal | python | https://github.com/saimn/sigal/blob/912ca39991355d358dc85fd55c7aeabdd7acc386/sigal/plugins/watermark.py#L55-L80 | [
"def",
"watermark",
"(",
"im",
",",
"mark",
",",
"position",
",",
"opacity",
"=",
"1",
")",
":",
"if",
"opacity",
"<",
"1",
":",
"mark",
"=",
"reduce_opacity",
"(",
"mark",
",",
"opacity",
")",
"if",
"im",
".",
"mode",
"!=",
"'RGBA'",
":",
"im",
... | 912ca39991355d358dc85fd55c7aeabdd7acc386 |
valid | check_subprocess | Run the command to resize the video and remove the output file if the
processing fails. | sigal/video.py | def check_subprocess(cmd, source, outname):
"""Run the command to resize the video and remove the output file if the
processing fails.
"""
logger = logging.getLogger(__name__)
try:
res = subprocess.run(cmd, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
exc... | def check_subprocess(cmd, source, outname):
"""Run the command to resize the video and remove the output file if the
processing fails.
"""
logger = logging.getLogger(__name__)
try:
res = subprocess.run(cmd, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
exc... | [
"Run",
"the",
"command",
"to",
"resize",
"the",
"video",
"and",
"remove",
"the",
"output",
"file",
"if",
"the",
"processing",
"fails",
"."
] | saimn/sigal | python | https://github.com/saimn/sigal/blob/912ca39991355d358dc85fd55c7aeabdd7acc386/sigal/video.py#L38-L59 | [
"def",
"check_subprocess",
"(",
"cmd",
",",
"source",
",",
"outname",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"try",
":",
"res",
"=",
"subprocess",
".",
"run",
"(",
"cmd",
",",
"stdout",
"=",
"subprocess",
".",
"PIPE... | 912ca39991355d358dc85fd55c7aeabdd7acc386 |
valid | video_size | Returns the dimensions of the video. | sigal/video.py | def video_size(source, converter='ffmpeg'):
"""Returns the dimensions of the video."""
res = subprocess.run([converter, '-i', source], stderr=subprocess.PIPE)
stderr = res.stderr.decode('utf8')
pattern = re.compile(r'Stream.*Video.* ([0-9]+)x([0-9]+)')
match = pattern.search(stderr)
rot_pattern... | def video_size(source, converter='ffmpeg'):
"""Returns the dimensions of the video."""
res = subprocess.run([converter, '-i', source], stderr=subprocess.PIPE)
stderr = res.stderr.decode('utf8')
pattern = re.compile(r'Stream.*Video.* ([0-9]+)x([0-9]+)')
match = pattern.search(stderr)
rot_pattern... | [
"Returns",
"the",
"dimensions",
"of",
"the",
"video",
"."
] | saimn/sigal | python | https://github.com/saimn/sigal/blob/912ca39991355d358dc85fd55c7aeabdd7acc386/sigal/video.py#L62-L78 | [
"def",
"video_size",
"(",
"source",
",",
"converter",
"=",
"'ffmpeg'",
")",
":",
"res",
"=",
"subprocess",
".",
"run",
"(",
"[",
"converter",
",",
"'-i'",
",",
"source",
"]",
",",
"stderr",
"=",
"subprocess",
".",
"PIPE",
")",
"stderr",
"=",
"res",
"... | 912ca39991355d358dc85fd55c7aeabdd7acc386 |
valid | generate_video | Video processor.
:param source: path to a video
:param outname: path to the generated video
:param settings: settings dict
:param options: array of options passed to ffmpeg | sigal/video.py | def generate_video(source, outname, settings, options=None):
"""Video processor.
:param source: path to a video
:param outname: path to the generated video
:param settings: settings dict
:param options: array of options passed to ffmpeg
"""
logger = logging.getLogger(__name__)
# Don't... | def generate_video(source, outname, settings, options=None):
"""Video processor.
:param source: path to a video
:param outname: path to the generated video
:param settings: settings dict
:param options: array of options passed to ffmpeg
"""
logger = logging.getLogger(__name__)
# Don't... | [
"Video",
"processor",
"."
] | saimn/sigal | python | https://github.com/saimn/sigal/blob/912ca39991355d358dc85fd55c7aeabdd7acc386/sigal/video.py#L81-L127 | [
"def",
"generate_video",
"(",
"source",
",",
"outname",
",",
"settings",
",",
"options",
"=",
"None",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"# Don't transcode if source is in the required format and",
"# has fitting datedimensions, ... | 912ca39991355d358dc85fd55c7aeabdd7acc386 |
valid | generate_thumbnail | Create a thumbnail image for the video source, based on ffmpeg. | sigal/video.py | def generate_thumbnail(source, outname, box, delay, fit=True, options=None,
converter='ffmpeg'):
"""Create a thumbnail image for the video source, based on ffmpeg."""
logger = logging.getLogger(__name__)
tmpfile = outname + ".tmp.jpg"
# dump an image of the video
cmd = [conv... | def generate_thumbnail(source, outname, box, delay, fit=True, options=None,
converter='ffmpeg'):
"""Create a thumbnail image for the video source, based on ffmpeg."""
logger = logging.getLogger(__name__)
tmpfile = outname + ".tmp.jpg"
# dump an image of the video
cmd = [conv... | [
"Create",
"a",
"thumbnail",
"image",
"for",
"the",
"video",
"source",
"based",
"on",
"ffmpeg",
"."
] | saimn/sigal | python | https://github.com/saimn/sigal/blob/912ca39991355d358dc85fd55c7aeabdd7acc386/sigal/video.py#L130-L146 | [
"def",
"generate_thumbnail",
"(",
"source",
",",
"outname",
",",
"box",
",",
"delay",
",",
"fit",
"=",
"True",
",",
"options",
"=",
"None",
",",
"converter",
"=",
"'ffmpeg'",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"... | 912ca39991355d358dc85fd55c7aeabdd7acc386 |
valid | process_video | Process a video: resize, create thumbnail. | sigal/video.py | def process_video(filepath, outpath, settings):
"""Process a video: resize, create thumbnail."""
logger = logging.getLogger(__name__)
filename = os.path.split(filepath)[1]
basename, ext = splitext(filename)
try:
if settings['use_orig'] and is_valid_html5_video(ext):
outname = o... | def process_video(filepath, outpath, settings):
"""Process a video: resize, create thumbnail."""
logger = logging.getLogger(__name__)
filename = os.path.split(filepath)[1]
basename, ext = splitext(filename)
try:
if settings['use_orig'] and is_valid_html5_video(ext):
outname = o... | [
"Process",
"a",
"video",
":",
"resize",
"create",
"thumbnail",
"."
] | saimn/sigal | python | https://github.com/saimn/sigal/blob/912ca39991355d358dc85fd55c7aeabdd7acc386/sigal/video.py#L149-L192 | [
"def",
"process_video",
"(",
"filepath",
",",
"outpath",
",",
"settings",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"filename",
"=",
"os",
".",
"path",
".",
"split",
"(",
"filepath",
")",
"[",
"1",
"]",
"basename",
","... | 912ca39991355d358dc85fd55c7aeabdd7acc386 |
valid | init_logging | Logging config
Set the level and create a more detailed formatter for debug mode. | sigal/log.py | def init_logging(name, level=logging.INFO):
"""Logging config
Set the level and create a more detailed formatter for debug mode.
"""
logger = logging.getLogger(name)
logger.setLevel(level)
try:
if os.isatty(sys.stdout.fileno()) and \
not sys.platform.startswith('win'):... | def init_logging(name, level=logging.INFO):
"""Logging config
Set the level and create a more detailed formatter for debug mode.
"""
logger = logging.getLogger(name)
logger.setLevel(level)
try:
if os.isatty(sys.stdout.fileno()) and \
not sys.platform.startswith('win'):... | [
"Logging",
"config"
] | saimn/sigal | python | https://github.com/saimn/sigal/blob/912ca39991355d358dc85fd55c7aeabdd7acc386/sigal/log.py#L57-L80 | [
"def",
"init_logging",
"(",
"name",
",",
"level",
"=",
"logging",
".",
"INFO",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"name",
")",
"logger",
".",
"setLevel",
"(",
"level",
")",
"try",
":",
"if",
"os",
".",
"isatty",
"(",
"sys",
... | 912ca39991355d358dc85fd55c7aeabdd7acc386 |
valid | AbstractWriter.generate_context | Generate the context dict for the given path. | sigal/writer.py | def generate_context(self, album):
"""Generate the context dict for the given path."""
from . import __url__ as sigal_link
self.logger.info("Output album : %r", album)
return {
'album': album,
'index_title': self.index_title,
'settings': self.settings... | def generate_context(self, album):
"""Generate the context dict for the given path."""
from . import __url__ as sigal_link
self.logger.info("Output album : %r", album)
return {
'album': album,
'index_title': self.index_title,
'settings': self.settings... | [
"Generate",
"the",
"context",
"dict",
"for",
"the",
"given",
"path",
"."
] | saimn/sigal | python | https://github.com/saimn/sigal/blob/912ca39991355d358dc85fd55c7aeabdd7acc386/sigal/writer.py#L98-L111 | [
"def",
"generate_context",
"(",
"self",
",",
"album",
")",
":",
"from",
".",
"import",
"__url__",
"as",
"sigal_link",
"self",
".",
"logger",
".",
"info",
"(",
"\"Output album : %r\"",
",",
"album",
")",
"return",
"{",
"'album'",
":",
"album",
",",
"'index_... | 912ca39991355d358dc85fd55c7aeabdd7acc386 |
valid | AbstractWriter.write | Generate the HTML page and save it. | sigal/writer.py | def write(self, album):
"""Generate the HTML page and save it."""
page = self.template.render(**self.generate_context(album))
output_file = os.path.join(album.dst_path, album.output_file)
with open(output_file, 'w', encoding='utf-8') as f:
f.write(page) | def write(self, album):
"""Generate the HTML page and save it."""
page = self.template.render(**self.generate_context(album))
output_file = os.path.join(album.dst_path, album.output_file)
with open(output_file, 'w', encoding='utf-8') as f:
f.write(page) | [
"Generate",
"the",
"HTML",
"page",
"and",
"save",
"it",
"."
] | saimn/sigal | python | https://github.com/saimn/sigal/blob/912ca39991355d358dc85fd55c7aeabdd7acc386/sigal/writer.py#L113-L120 | [
"def",
"write",
"(",
"self",
",",
"album",
")",
":",
"page",
"=",
"self",
".",
"template",
".",
"render",
"(",
"*",
"*",
"self",
".",
"generate_context",
"(",
"album",
")",
")",
"output_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"album",
".",... | 912ca39991355d358dc85fd55c7aeabdd7acc386 |
valid | get_thumb | Return the path to the thumb.
examples:
>>> default_settings = create_settings()
>>> get_thumb(default_settings, "bar/foo.jpg")
"bar/thumbnails/foo.jpg"
>>> get_thumb(default_settings, "bar/foo.png")
"bar/thumbnails/foo.png"
for videos, it returns a jpg file:
>>> get_thumb(default_sett... | sigal/settings.py | def get_thumb(settings, filename):
"""Return the path to the thumb.
examples:
>>> default_settings = create_settings()
>>> get_thumb(default_settings, "bar/foo.jpg")
"bar/thumbnails/foo.jpg"
>>> get_thumb(default_settings, "bar/foo.png")
"bar/thumbnails/foo.png"
for videos, it returns ... | def get_thumb(settings, filename):
"""Return the path to the thumb.
examples:
>>> default_settings = create_settings()
>>> get_thumb(default_settings, "bar/foo.jpg")
"bar/thumbnails/foo.jpg"
>>> get_thumb(default_settings, "bar/foo.png")
"bar/thumbnails/foo.png"
for videos, it returns ... | [
"Return",
"the",
"path",
"to",
"the",
"thumb",
"."
] | saimn/sigal | python | https://github.com/saimn/sigal/blob/912ca39991355d358dc85fd55c7aeabdd7acc386/sigal/settings.py#L94-L115 | [
"def",
"get_thumb",
"(",
"settings",
",",
"filename",
")",
":",
"path",
",",
"filen",
"=",
"os",
".",
"path",
".",
"split",
"(",
"filename",
")",
"name",
",",
"ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"filen",
")",
"if",
"ext",
".",
"l... | 912ca39991355d358dc85fd55c7aeabdd7acc386 |
valid | read_settings | Read settings from a config file in the source_dir root. | sigal/settings.py | def read_settings(filename=None):
"""Read settings from a config file in the source_dir root."""
logger = logging.getLogger(__name__)
logger.info("Reading settings ...")
settings = _DEFAULT_CONFIG.copy()
if filename:
logger.debug("Settings file: %s", filename)
settings_path = os.pa... | def read_settings(filename=None):
"""Read settings from a config file in the source_dir root."""
logger = logging.getLogger(__name__)
logger.info("Reading settings ...")
settings = _DEFAULT_CONFIG.copy()
if filename:
logger.debug("Settings file: %s", filename)
settings_path = os.pa... | [
"Read",
"settings",
"from",
"a",
"config",
"file",
"in",
"the",
"source_dir",
"root",
"."
] | saimn/sigal | python | https://github.com/saimn/sigal/blob/912ca39991355d358dc85fd55c7aeabdd7acc386/sigal/settings.py#L118-L162 | [
"def",
"read_settings",
"(",
"filename",
"=",
"None",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"logger",
".",
"info",
"(",
"\"Reading settings ...\"",
")",
"settings",
"=",
"_DEFAULT_CONFIG",
".",
"copy",
"(",
")",
"if",
... | 912ca39991355d358dc85fd55c7aeabdd7acc386 |
valid | generate_media_pages | Generates and writes the media pages for all media in the gallery | sigal/plugins/media_page.py | def generate_media_pages(gallery):
'''Generates and writes the media pages for all media in the gallery'''
writer = PageWriter(gallery.settings, index_title=gallery.title)
for album in gallery.albums.values():
medias = album.medias
next_medias = medias[1:] + [None]
previous_medias ... | def generate_media_pages(gallery):
'''Generates and writes the media pages for all media in the gallery'''
writer = PageWriter(gallery.settings, index_title=gallery.title)
for album in gallery.albums.values():
medias = album.medias
next_medias = medias[1:] + [None]
previous_medias ... | [
"Generates",
"and",
"writes",
"the",
"media",
"pages",
"for",
"all",
"media",
"in",
"the",
"gallery"
] | saimn/sigal | python | https://github.com/saimn/sigal/blob/912ca39991355d358dc85fd55c7aeabdd7acc386/sigal/plugins/media_page.py#L69-L83 | [
"def",
"generate_media_pages",
"(",
"gallery",
")",
":",
"writer",
"=",
"PageWriter",
"(",
"gallery",
".",
"settings",
",",
"index_title",
"=",
"gallery",
".",
"title",
")",
"for",
"album",
"in",
"gallery",
".",
"albums",
".",
"values",
"(",
")",
":",
"m... | 912ca39991355d358dc85fd55c7aeabdd7acc386 |
valid | PageWriter.write | Generate the media page and save it | sigal/plugins/media_page.py | def write(self, album, media_group):
''' Generate the media page and save it '''
from sigal import __url__ as sigal_link
file_path = os.path.join(album.dst_path, media_group[0].filename)
page = self.template.render({
'album': album,
'media': media_group[0],
... | def write(self, album, media_group):
''' Generate the media page and save it '''
from sigal import __url__ as sigal_link
file_path = os.path.join(album.dst_path, media_group[0].filename)
page = self.template.render({
'album': album,
'media': media_group[0],
... | [
"Generate",
"the",
"media",
"page",
"and",
"save",
"it"
] | saimn/sigal | python | https://github.com/saimn/sigal/blob/912ca39991355d358dc85fd55c7aeabdd7acc386/sigal/plugins/media_page.py#L44-L66 | [
"def",
"write",
"(",
"self",
",",
"album",
",",
"media_group",
")",
":",
"from",
"sigal",
"import",
"__url__",
"as",
"sigal_link",
"file_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"album",
".",
"dst_path",
",",
"media_group",
"[",
"0",
"]",
".",
... | 912ca39991355d358dc85fd55c7aeabdd7acc386 |
valid | check_install | Here we do some **really** basic environment sanity checks.
Basically we test for the more delicate and failing-prone dependencies:
* database driver
* Pillow image format support
Many other errors will go undetected | djangocms_installer/install/__init__.py | def check_install(config_data):
"""
Here we do some **really** basic environment sanity checks.
Basically we test for the more delicate and failing-prone dependencies:
* database driver
* Pillow image format support
Many other errors will go undetected
"""
errors = []
# PIL test... | def check_install(config_data):
"""
Here we do some **really** basic environment sanity checks.
Basically we test for the more delicate and failing-prone dependencies:
* database driver
* Pillow image format support
Many other errors will go undetected
"""
errors = []
# PIL test... | [
"Here",
"we",
"do",
"some",
"**",
"really",
"**",
"basic",
"environment",
"sanity",
"checks",
"."
] | nephila/djangocms-installer | python | https://github.com/nephila/djangocms-installer/blob/9fec66d5f8b1e9a0f3c0ec66dd777db578fab07e/djangocms_installer/install/__init__.py#L15-L79 | [
"def",
"check_install",
"(",
"config_data",
")",
":",
"errors",
"=",
"[",
"]",
"# PIL tests",
"try",
":",
"from",
"PIL",
"import",
"Image",
"try",
":",
"im",
"=",
"Image",
".",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".... | 9fec66d5f8b1e9a0f3c0ec66dd777db578fab07e |
valid | cleanup_directory | Asks user for removal of project directory and eventually removes it | djangocms_installer/install/__init__.py | def cleanup_directory(config_data):
"""
Asks user for removal of project directory and eventually removes it
"""
if os.path.exists(config_data.project_directory):
choice = False
if config_data.noinput is False and not config_data.verbose:
choice = query_yes_no(
... | def cleanup_directory(config_data):
"""
Asks user for removal of project directory and eventually removes it
"""
if os.path.exists(config_data.project_directory):
choice = False
if config_data.noinput is False and not config_data.verbose:
choice = query_yes_no(
... | [
"Asks",
"user",
"for",
"removal",
"of",
"project",
"directory",
"and",
"eventually",
"removes",
"it"
] | nephila/djangocms-installer | python | https://github.com/nephila/djangocms-installer/blob/9fec66d5f8b1e9a0f3c0ec66dd777db578fab07e/djangocms_installer/install/__init__.py#L121-L146 | [
"def",
"cleanup_directory",
"(",
"config_data",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"config_data",
".",
"project_directory",
")",
":",
"choice",
"=",
"False",
"if",
"config_data",
".",
"noinput",
"is",
"False",
"and",
"not",
"config_data",... | 9fec66d5f8b1e9a0f3c0ec66dd777db578fab07e |
valid | validate_project | Check the defined project name against keywords, builtins and existing
modules to avoid name clashing | djangocms_installer/config/internal.py | def validate_project(project_name):
"""
Check the defined project name against keywords, builtins and existing
modules to avoid name clashing
"""
if '-' in project_name:
return None
if keyword.iskeyword(project_name):
return None
if project_name in dir(__builtins__):
... | def validate_project(project_name):
"""
Check the defined project name against keywords, builtins and existing
modules to avoid name clashing
"""
if '-' in project_name:
return None
if keyword.iskeyword(project_name):
return None
if project_name in dir(__builtins__):
... | [
"Check",
"the",
"defined",
"project",
"name",
"against",
"keywords",
"builtins",
"and",
"existing",
"modules",
"to",
"avoid",
"name",
"clashing"
] | nephila/djangocms-installer | python | https://github.com/nephila/djangocms-installer/blob/9fec66d5f8b1e9a0f3c0ec66dd777db578fab07e/djangocms_installer/config/internal.py#L28-L43 | [
"def",
"validate_project",
"(",
"project_name",
")",
":",
"if",
"'-'",
"in",
"project_name",
":",
"return",
"None",
"if",
"keyword",
".",
"iskeyword",
"(",
"project_name",
")",
":",
"return",
"None",
"if",
"project_name",
"in",
"dir",
"(",
"__builtins__",
")... | 9fec66d5f8b1e9a0f3c0ec66dd777db578fab07e |
valid | parse | Define the available arguments | djangocms_installer/config/__init__.py | def parse(args):
"""
Define the available arguments
"""
from tzlocal import get_localzone
try:
timezone = get_localzone()
if isinstance(timezone, pytz.BaseTzInfo):
timezone = timezone.zone
except Exception: # pragma: no cover
timezone = 'UTC'
if timezone... | def parse(args):
"""
Define the available arguments
"""
from tzlocal import get_localzone
try:
timezone = get_localzone()
if isinstance(timezone, pytz.BaseTzInfo):
timezone = timezone.zone
except Exception: # pragma: no cover
timezone = 'UTC'
if timezone... | [
"Define",
"the",
"available",
"arguments"
] | nephila/djangocms-installer | python | https://github.com/nephila/djangocms-installer/blob/9fec66d5f8b1e9a0f3c0ec66dd777db578fab07e/djangocms_installer/config/__init__.py#L20-L337 | [
"def",
"parse",
"(",
"args",
")",
":",
"from",
"tzlocal",
"import",
"get_localzone",
"try",
":",
"timezone",
"=",
"get_localzone",
"(",
")",
"if",
"isinstance",
"(",
"timezone",
",",
"pytz",
".",
"BaseTzInfo",
")",
":",
"timezone",
"=",
"timezone",
".",
... | 9fec66d5f8b1e9a0f3c0ec66dd777db578fab07e |
valid | _manage_args | Checks and validate provided input | djangocms_installer/config/__init__.py | def _manage_args(parser, args):
"""
Checks and validate provided input
"""
for item in data.CONFIGURABLE_OPTIONS:
action = parser._option_string_actions[item]
choices = default = ''
input_value = getattr(args, action.dest)
new_val = None
# cannot count this until... | def _manage_args(parser, args):
"""
Checks and validate provided input
"""
for item in data.CONFIGURABLE_OPTIONS:
action = parser._option_string_actions[item]
choices = default = ''
input_value = getattr(args, action.dest)
new_val = None
# cannot count this until... | [
"Checks",
"and",
"validate",
"provided",
"input"
] | nephila/djangocms-installer | python | https://github.com/nephila/djangocms-installer/blob/9fec66d5f8b1e9a0f3c0ec66dd777db578fab07e/djangocms_installer/config/__init__.py#L363-L412 | [
"def",
"_manage_args",
"(",
"parser",
",",
"args",
")",
":",
"for",
"item",
"in",
"data",
".",
"CONFIGURABLE_OPTIONS",
":",
"action",
"=",
"parser",
".",
"_option_string_actions",
"[",
"item",
"]",
"choices",
"=",
"default",
"=",
"''",
"input_value",
"=",
... | 9fec66d5f8b1e9a0f3c0ec66dd777db578fab07e |
valid | query_yes_no | Ask a yes/no question via `raw_input()` and return their answer.
:param question: A string that is presented to the user.
:param default: The presumed answer if the user just hits <Enter>.
It must be "yes" (the default), "no" or None (meaning
an answer is required of the... | djangocms_installer/utils.py | def query_yes_no(question, default=None): # pragma: no cover
"""
Ask a yes/no question via `raw_input()` and return their answer.
:param question: A string that is presented to the user.
:param default: The presumed answer if the user just hits <Enter>.
It must be "yes" (the defaul... | def query_yes_no(question, default=None): # pragma: no cover
"""
Ask a yes/no question via `raw_input()` and return their answer.
:param question: A string that is presented to the user.
:param default: The presumed answer if the user just hits <Enter>.
It must be "yes" (the defaul... | [
"Ask",
"a",
"yes",
"/",
"no",
"question",
"via",
"raw_input",
"()",
"and",
"return",
"their",
"answer",
"."
] | nephila/djangocms-installer | python | https://github.com/nephila/djangocms-installer/blob/9fec66d5f8b1e9a0f3c0ec66dd777db578fab07e/djangocms_installer/utils.py#L15-L48 | [
"def",
"query_yes_no",
"(",
"question",
",",
"default",
"=",
"None",
")",
":",
"# pragma: no cover",
"valid",
"=",
"{",
"'yes'",
":",
"True",
",",
"'y'",
":",
"True",
",",
"'ye'",
":",
"True",
",",
"'no'",
":",
"False",
",",
"'n'",
":",
"False",
"}",... | 9fec66d5f8b1e9a0f3c0ec66dd777db578fab07e |
valid | supported_versions | Convert numeric and literal version information to numeric format | djangocms_installer/utils.py | def supported_versions(django, cms):
"""
Convert numeric and literal version information to numeric format
"""
cms_version = None
django_version = None
try:
cms_version = Decimal(cms)
except (ValueError, InvalidOperation):
try:
cms_version = CMS_VERSION_MATRIX[st... | def supported_versions(django, cms):
"""
Convert numeric and literal version information to numeric format
"""
cms_version = None
django_version = None
try:
cms_version = Decimal(cms)
except (ValueError, InvalidOperation):
try:
cms_version = CMS_VERSION_MATRIX[st... | [
"Convert",
"numeric",
"and",
"literal",
"version",
"information",
"to",
"numeric",
"format"
] | nephila/djangocms-installer | python | https://github.com/nephila/djangocms-installer/blob/9fec66d5f8b1e9a0f3c0ec66dd777db578fab07e/djangocms_installer/utils.py#L51-L93 | [
"def",
"supported_versions",
"(",
"django",
",",
"cms",
")",
":",
"cms_version",
"=",
"None",
"django_version",
"=",
"None",
"try",
":",
"cms_version",
"=",
"Decimal",
"(",
"cms",
")",
"except",
"(",
"ValueError",
",",
"InvalidOperation",
")",
":",
"try",
... | 9fec66d5f8b1e9a0f3c0ec66dd777db578fab07e |
valid | less_than_version | Converts the current version to the next one for inserting into requirements
in the ' < version' format | djangocms_installer/utils.py | def less_than_version(value):
"""
Converts the current version to the next one for inserting into requirements
in the ' < version' format
"""
items = list(map(int, str(value).split('.')))
if len(items) == 1:
items.append(0)
items[1] += 1
if value == '1.11':
return '2.0'
... | def less_than_version(value):
"""
Converts the current version to the next one for inserting into requirements
in the ' < version' format
"""
items = list(map(int, str(value).split('.')))
if len(items) == 1:
items.append(0)
items[1] += 1
if value == '1.11':
return '2.0'
... | [
"Converts",
"the",
"current",
"version",
"to",
"the",
"next",
"one",
"for",
"inserting",
"into",
"requirements",
"in",
"the",
"<",
"version",
"format"
] | nephila/djangocms-installer | python | https://github.com/nephila/djangocms-installer/blob/9fec66d5f8b1e9a0f3c0ec66dd777db578fab07e/djangocms_installer/utils.py#L96-L108 | [
"def",
"less_than_version",
"(",
"value",
")",
":",
"items",
"=",
"list",
"(",
"map",
"(",
"int",
",",
"str",
"(",
"value",
")",
".",
"split",
"(",
"'.'",
")",
")",
")",
"if",
"len",
"(",
"items",
")",
"==",
"1",
":",
"items",
".",
"append",
"(... | 9fec66d5f8b1e9a0f3c0ec66dd777db578fab07e |
valid | format_val | Returns val as integer or as escaped string according to its value
:param val: any value
:return: formatted string | djangocms_installer/utils.py | def format_val(val):
"""
Returns val as integer or as escaped string according to its value
:param val: any value
:return: formatted string
"""
val = text_type(val)
if val.isdigit():
return int(val)
else:
return '\'{0}\''.format(val) | def format_val(val):
"""
Returns val as integer or as escaped string according to its value
:param val: any value
:return: formatted string
"""
val = text_type(val)
if val.isdigit():
return int(val)
else:
return '\'{0}\''.format(val) | [
"Returns",
"val",
"as",
"integer",
"or",
"as",
"escaped",
"string",
"according",
"to",
"its",
"value",
":",
"param",
"val",
":",
"any",
"value",
":",
"return",
":",
"formatted",
"string"
] | nephila/djangocms-installer | python | https://github.com/nephila/djangocms-installer/blob/9fec66d5f8b1e9a0f3c0ec66dd777db578fab07e/djangocms_installer/utils.py#L126-L136 | [
"def",
"format_val",
"(",
"val",
")",
":",
"val",
"=",
"text_type",
"(",
"val",
")",
"if",
"val",
".",
"isdigit",
"(",
")",
":",
"return",
"int",
"(",
"val",
")",
"else",
":",
"return",
"'\\'{0}\\''",
".",
"format",
"(",
"val",
")"
] | 9fec66d5f8b1e9a0f3c0ec66dd777db578fab07e |
valid | parse_config_file | Parse config file.
Returns a list of additional args. | djangocms_installer/config/ini.py | def parse_config_file(parser, stdin_args):
"""Parse config file.
Returns a list of additional args.
"""
config_args = []
# Temporary switch required args and save them to restore.
required_args = []
for action in parser._actions:
if action.required:
required_args.append... | def parse_config_file(parser, stdin_args):
"""Parse config file.
Returns a list of additional args.
"""
config_args = []
# Temporary switch required args and save them to restore.
required_args = []
for action in parser._actions:
if action.required:
required_args.append... | [
"Parse",
"config",
"file",
"."
] | nephila/djangocms-installer | python | https://github.com/nephila/djangocms-installer/blob/9fec66d5f8b1e9a0f3c0ec66dd777db578fab07e/djangocms_installer/config/ini.py#L17-L46 | [
"def",
"parse_config_file",
"(",
"parser",
",",
"stdin_args",
")",
":",
"config_args",
"=",
"[",
"]",
"# Temporary switch required args and save them to restore.",
"required_args",
"=",
"[",
"]",
"for",
"action",
"in",
"parser",
".",
"_actions",
":",
"if",
"action",... | 9fec66d5f8b1e9a0f3c0ec66dd777db578fab07e |
valid | dump_config_file | Dump args to config file. | djangocms_installer/config/ini.py | def dump_config_file(filename, args, parser=None):
"""Dump args to config file."""
config = ConfigParser()
config.add_section(SECTION)
if parser is None:
for attr in args:
config.set(SECTION, attr, args.attr)
else:
keys_empty_values_not_pass = (
'--extra-setti... | def dump_config_file(filename, args, parser=None):
"""Dump args to config file."""
config = ConfigParser()
config.add_section(SECTION)
if parser is None:
for attr in args:
config.set(SECTION, attr, args.attr)
else:
keys_empty_values_not_pass = (
'--extra-setti... | [
"Dump",
"args",
"to",
"config",
"file",
"."
] | nephila/djangocms-installer | python | https://github.com/nephila/djangocms-installer/blob/9fec66d5f8b1e9a0f3c0ec66dd777db578fab07e/djangocms_installer/config/ini.py#L49-L93 | [
"def",
"dump_config_file",
"(",
"filename",
",",
"args",
",",
"parser",
"=",
"None",
")",
":",
"config",
"=",
"ConfigParser",
"(",
")",
"config",
".",
"add_section",
"(",
"SECTION",
")",
"if",
"parser",
"is",
"None",
":",
"for",
"attr",
"in",
"args",
"... | 9fec66d5f8b1e9a0f3c0ec66dd777db578fab07e |
valid | _convert_config_to_stdin | Convert config options to stdin args.
Especially boolean values, for more information
@see https://docs.python.org/3.4/library/configparser.html#supported-datatypes | djangocms_installer/config/ini.py | def _convert_config_to_stdin(config, parser):
"""Convert config options to stdin args.
Especially boolean values, for more information
@see https://docs.python.org/3.4/library/configparser.html#supported-datatypes
"""
keys_empty_values_not_pass = (
'--extra-settings', '--languages', '--requ... | def _convert_config_to_stdin(config, parser):
"""Convert config options to stdin args.
Especially boolean values, for more information
@see https://docs.python.org/3.4/library/configparser.html#supported-datatypes
"""
keys_empty_values_not_pass = (
'--extra-settings', '--languages', '--requ... | [
"Convert",
"config",
"options",
"to",
"stdin",
"args",
"."
] | nephila/djangocms-installer | python | https://github.com/nephila/djangocms-installer/blob/9fec66d5f8b1e9a0f3c0ec66dd777db578fab07e/djangocms_installer/config/ini.py#L96-L123 | [
"def",
"_convert_config_to_stdin",
"(",
"config",
",",
"parser",
")",
":",
"keys_empty_values_not_pass",
"=",
"(",
"'--extra-settings'",
",",
"'--languages'",
",",
"'--requirements'",
",",
"'--template'",
",",
"'--timezone'",
")",
"args",
"=",
"[",
"]",
"for",
"ke... | 9fec66d5f8b1e9a0f3c0ec66dd777db578fab07e |
valid | create_project | Call django-admin to create the project structure
:param config_data: configuration data | djangocms_installer/django/__init__.py | def create_project(config_data):
"""
Call django-admin to create the project structure
:param config_data: configuration data
"""
env = deepcopy(dict(os.environ))
env[str('DJANGO_SETTINGS_MODULE')] = str('{0}.settings'.format(config_data.project_name))
env[str('PYTHONPATH')] = str(os.pathse... | def create_project(config_data):
"""
Call django-admin to create the project structure
:param config_data: configuration data
"""
env = deepcopy(dict(os.environ))
env[str('DJANGO_SETTINGS_MODULE')] = str('{0}.settings'.format(config_data.project_name))
env[str('PYTHONPATH')] = str(os.pathse... | [
"Call",
"django",
"-",
"admin",
"to",
"create",
"the",
"project",
"structure"
] | nephila/djangocms-installer | python | https://github.com/nephila/djangocms-installer/blob/9fec66d5f8b1e9a0f3c0ec66dd777db578fab07e/djangocms_installer/django/__init__.py#L27-L66 | [
"def",
"create_project",
"(",
"config_data",
")",
":",
"env",
"=",
"deepcopy",
"(",
"dict",
"(",
"os",
".",
"environ",
")",
")",
"env",
"[",
"str",
"(",
"'DJANGO_SETTINGS_MODULE'",
")",
"]",
"=",
"str",
"(",
"'{0}.settings'",
".",
"format",
"(",
"config_... | 9fec66d5f8b1e9a0f3c0ec66dd777db578fab07e |
valid | _detect_migration_layout | Detect migrations layout for plugins
:param vars: installer settings
:param apps: installed applications | djangocms_installer/django/__init__.py | def _detect_migration_layout(vars, apps):
"""
Detect migrations layout for plugins
:param vars: installer settings
:param apps: installed applications
"""
DJANGO_MODULES = {}
for module in vars.MIGRATIONS_CHECK_MODULES:
if module in apps:
try:
mod = __imp... | def _detect_migration_layout(vars, apps):
"""
Detect migrations layout for plugins
:param vars: installer settings
:param apps: installed applications
"""
DJANGO_MODULES = {}
for module in vars.MIGRATIONS_CHECK_MODULES:
if module in apps:
try:
mod = __imp... | [
"Detect",
"migrations",
"layout",
"for",
"plugins",
":",
"param",
"vars",
":",
"installer",
"settings",
":",
"param",
"apps",
":",
"installed",
"applications"
] | nephila/djangocms-installer | python | https://github.com/nephila/djangocms-installer/blob/9fec66d5f8b1e9a0f3c0ec66dd777db578fab07e/djangocms_installer/django/__init__.py#L69-L84 | [
"def",
"_detect_migration_layout",
"(",
"vars",
",",
"apps",
")",
":",
"DJANGO_MODULES",
"=",
"{",
"}",
"for",
"module",
"in",
"vars",
".",
"MIGRATIONS_CHECK_MODULES",
":",
"if",
"module",
"in",
"apps",
":",
"try",
":",
"mod",
"=",
"__import__",
"(",
"'{0}... | 9fec66d5f8b1e9a0f3c0ec66dd777db578fab07e |
valid | _install_aldryn | Install aldryn boilerplate
:param config_data: configuration data | djangocms_installer/django/__init__.py | def _install_aldryn(config_data): # pragma: no cover
"""
Install aldryn boilerplate
:param config_data: configuration data
"""
import requests
media_project = os.path.join(config_data.project_directory, 'dist', 'media')
static_main = False
static_project = os.path.join(config_data.proj... | def _install_aldryn(config_data): # pragma: no cover
"""
Install aldryn boilerplate
:param config_data: configuration data
"""
import requests
media_project = os.path.join(config_data.project_directory, 'dist', 'media')
static_main = False
static_project = os.path.join(config_data.proj... | [
"Install",
"aldryn",
"boilerplate"
] | nephila/djangocms-installer | python | https://github.com/nephila/djangocms-installer/blob/9fec66d5f8b1e9a0f3c0ec66dd777db578fab07e/djangocms_installer/django/__init__.py#L87-L110 | [
"def",
"_install_aldryn",
"(",
"config_data",
")",
":",
"# pragma: no cover",
"import",
"requests",
"media_project",
"=",
"os",
".",
"path",
".",
"join",
"(",
"config_data",
".",
"project_directory",
",",
"'dist'",
",",
"'media'",
")",
"static_main",
"=",
"False... | 9fec66d5f8b1e9a0f3c0ec66dd777db578fab07e |
valid | copy_files | It's a little rude actually: it just overwrites the django-generated urls.py
with a custom version and put other files in the project directory.
:param config_data: configuration data | djangocms_installer/django/__init__.py | def copy_files(config_data):
"""
It's a little rude actually: it just overwrites the django-generated urls.py
with a custom version and put other files in the project directory.
:param config_data: configuration data
"""
if config_data.i18n == 'yes':
urlconf_path = os.path.join(os.path.... | def copy_files(config_data):
"""
It's a little rude actually: it just overwrites the django-generated urls.py
with a custom version and put other files in the project directory.
:param config_data: configuration data
"""
if config_data.i18n == 'yes':
urlconf_path = os.path.join(os.path.... | [
"It",
"s",
"a",
"little",
"rude",
"actually",
":",
"it",
"just",
"overwrites",
"the",
"django",
"-",
"generated",
"urls",
".",
"py",
"with",
"a",
"custom",
"version",
"and",
"put",
"other",
"files",
"in",
"the",
"project",
"directory",
"."
] | nephila/djangocms-installer | python | https://github.com/nephila/djangocms-installer/blob/9fec66d5f8b1e9a0f3c0ec66dd777db578fab07e/djangocms_installer/django/__init__.py#L113-L161 | [
"def",
"copy_files",
"(",
"config_data",
")",
":",
"if",
"config_data",
".",
"i18n",
"==",
"'yes'",
":",
"urlconf_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
",",
"'../config/urls_i18n.py'",
"... | 9fec66d5f8b1e9a0f3c0ec66dd777db578fab07e |
valid | patch_settings | Modify the settings file created by Django injecting the django CMS
configuration
:param config_data: configuration data | djangocms_installer/django/__init__.py | def patch_settings(config_data):
"""
Modify the settings file created by Django injecting the django CMS
configuration
:param config_data: configuration data
"""
import django
current_django_version = LooseVersion(django.__version__)
declared_django_version = LooseVersion(config_data.dj... | def patch_settings(config_data):
"""
Modify the settings file created by Django injecting the django CMS
configuration
:param config_data: configuration data
"""
import django
current_django_version = LooseVersion(django.__version__)
declared_django_version = LooseVersion(config_data.dj... | [
"Modify",
"the",
"settings",
"file",
"created",
"by",
"Django",
"injecting",
"the",
"django",
"CMS",
"configuration"
] | nephila/djangocms-installer | python | https://github.com/nephila/djangocms-installer/blob/9fec66d5f8b1e9a0f3c0ec66dd777db578fab07e/djangocms_installer/django/__init__.py#L164-L272 | [
"def",
"patch_settings",
"(",
"config_data",
")",
":",
"import",
"django",
"current_django_version",
"=",
"LooseVersion",
"(",
"django",
".",
"__version__",
")",
"declared_django_version",
"=",
"LooseVersion",
"(",
"config_data",
".",
"django_version",
")",
"if",
"n... | 9fec66d5f8b1e9a0f3c0ec66dd777db578fab07e |
valid | _build_settings | Build the django CMS settings dictionary
:param config_data: configuration data | djangocms_installer/django/__init__.py | def _build_settings(config_data):
"""
Build the django CMS settings dictionary
:param config_data: configuration data
"""
spacer = ' '
text = []
vars = get_settings()
vars.MIDDLEWARE_CLASSES.insert(0, vars.APPHOOK_RELOAD_MIDDLEWARE_CLASS)
processors = vars.TEMPLATE_CONTEXT_PROC... | def _build_settings(config_data):
"""
Build the django CMS settings dictionary
:param config_data: configuration data
"""
spacer = ' '
text = []
vars = get_settings()
vars.MIDDLEWARE_CLASSES.insert(0, vars.APPHOOK_RELOAD_MIDDLEWARE_CLASS)
processors = vars.TEMPLATE_CONTEXT_PROC... | [
"Build",
"the",
"django",
"CMS",
"settings",
"dictionary"
] | nephila/djangocms-installer | python | https://github.com/nephila/djangocms-installer/blob/9fec66d5f8b1e9a0f3c0ec66dd777db578fab07e/djangocms_installer/django/__init__.py#L275-L402 | [
"def",
"_build_settings",
"(",
"config_data",
")",
":",
"spacer",
"=",
"' '",
"text",
"=",
"[",
"]",
"vars",
"=",
"get_settings",
"(",
")",
"vars",
".",
"MIDDLEWARE_CLASSES",
".",
"insert",
"(",
"0",
",",
"vars",
".",
"APPHOOK_RELOAD_MIDDLEWARE_CLASS",
")... | 9fec66d5f8b1e9a0f3c0ec66dd777db578fab07e |
valid | setup_database | Run the migrate command to create the database schema
:param config_data: configuration data | djangocms_installer/django/__init__.py | def setup_database(config_data):
"""
Run the migrate command to create the database schema
:param config_data: configuration data
"""
with chdir(config_data.project_directory):
env = deepcopy(dict(os.environ))
env[str('DJANGO_SETTINGS_MODULE')] = str('{0}.settings'.format(config_dat... | def setup_database(config_data):
"""
Run the migrate command to create the database schema
:param config_data: configuration data
"""
with chdir(config_data.project_directory):
env = deepcopy(dict(os.environ))
env[str('DJANGO_SETTINGS_MODULE')] = str('{0}.settings'.format(config_dat... | [
"Run",
"the",
"migrate",
"command",
"to",
"create",
"the",
"database",
"schema"
] | nephila/djangocms-installer | python | https://github.com/nephila/djangocms-installer/blob/9fec66d5f8b1e9a0f3c0ec66dd777db578fab07e/djangocms_installer/django/__init__.py#L405-L445 | [
"def",
"setup_database",
"(",
"config_data",
")",
":",
"with",
"chdir",
"(",
"config_data",
".",
"project_directory",
")",
":",
"env",
"=",
"deepcopy",
"(",
"dict",
"(",
"os",
".",
"environ",
")",
")",
"env",
"[",
"str",
"(",
"'DJANGO_SETTINGS_MODULE'",
")... | 9fec66d5f8b1e9a0f3c0ec66dd777db578fab07e |
valid | create_user | Create admin user without user input
:param config_data: configuration data | djangocms_installer/django/__init__.py | def create_user(config_data):
"""
Create admin user without user input
:param config_data: configuration data
"""
with chdir(os.path.abspath(config_data.project_directory)):
env = deepcopy(dict(os.environ))
env[str('DJANGO_SETTINGS_MODULE')] = str('{0}.settings'.format(config_data.p... | def create_user(config_data):
"""
Create admin user without user input
:param config_data: configuration data
"""
with chdir(os.path.abspath(config_data.project_directory)):
env = deepcopy(dict(os.environ))
env[str('DJANGO_SETTINGS_MODULE')] = str('{0}.settings'.format(config_data.p... | [
"Create",
"admin",
"user",
"without",
"user",
"input"
] | nephila/djangocms-installer | python | https://github.com/nephila/djangocms-installer/blob/9fec66d5f8b1e9a0f3c0ec66dd777db578fab07e/djangocms_installer/django/__init__.py#L448-L465 | [
"def",
"create_user",
"(",
"config_data",
")",
":",
"with",
"chdir",
"(",
"os",
".",
"path",
".",
"abspath",
"(",
"config_data",
".",
"project_directory",
")",
")",
":",
"env",
"=",
"deepcopy",
"(",
"dict",
"(",
"os",
".",
"environ",
")",
")",
"env",
... | 9fec66d5f8b1e9a0f3c0ec66dd777db578fab07e |
valid | sox | Pass an argument list to SoX.
Parameters
----------
args : iterable
Argument list for SoX. The first item can, but does not
need to, be 'sox'.
Returns:
--------
status : bool
True on success. | sox/core.py | def sox(args):
'''Pass an argument list to SoX.
Parameters
----------
args : iterable
Argument list for SoX. The first item can, but does not
need to, be 'sox'.
Returns:
--------
status : bool
True on success.
'''
if args[0].lower() != "sox":
args.i... | def sox(args):
'''Pass an argument list to SoX.
Parameters
----------
args : iterable
Argument list for SoX. The first item can, but does not
need to, be 'sox'.
Returns:
--------
status : bool
True on success.
'''
if args[0].lower() != "sox":
args.i... | [
"Pass",
"an",
"argument",
"list",
"to",
"SoX",
"."
] | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/core.py#L17-L55 | [
"def",
"sox",
"(",
"args",
")",
":",
"if",
"args",
"[",
"0",
"]",
".",
"lower",
"(",
")",
"!=",
"\"sox\"",
":",
"args",
".",
"insert",
"(",
"0",
",",
"\"sox\"",
")",
"else",
":",
"args",
"[",
"0",
"]",
"=",
"\"sox\"",
"try",
":",
"logger",
".... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | _get_valid_formats | Calls SoX help for a lists of audio formats available with the current
install of SoX.
Returns:
--------
formats : list
List of audio file extensions that SoX can process. | sox/core.py | def _get_valid_formats():
''' Calls SoX help for a lists of audio formats available with the current
install of SoX.
Returns:
--------
formats : list
List of audio file extensions that SoX can process.
'''
if NO_SOX:
return []
so = subprocess.check_output(['sox', '-h']... | def _get_valid_formats():
''' Calls SoX help for a lists of audio formats available with the current
install of SoX.
Returns:
--------
formats : list
List of audio file extensions that SoX can process.
'''
if NO_SOX:
return []
so = subprocess.check_output(['sox', '-h']... | [
"Calls",
"SoX",
"help",
"for",
"a",
"lists",
"of",
"audio",
"formats",
"available",
"with",
"the",
"current",
"install",
"of",
"SoX",
"."
] | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/core.py#L65-L85 | [
"def",
"_get_valid_formats",
"(",
")",
":",
"if",
"NO_SOX",
":",
"return",
"[",
"]",
"so",
"=",
"subprocess",
".",
"check_output",
"(",
"[",
"'sox'",
",",
"'-h'",
"]",
")",
"if",
"type",
"(",
"so",
")",
"is",
"not",
"str",
":",
"so",
"=",
"str",
... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | soxi | Base call to SoXI.
Parameters
----------
filepath : str
Path to audio file.
argument : str
Argument to pass to SoXI.
Returns
-------
shell_output : str
Command line output of SoXI | sox/core.py | def soxi(filepath, argument):
''' Base call to SoXI.
Parameters
----------
filepath : str
Path to audio file.
argument : str
Argument to pass to SoXI.
Returns
-------
shell_output : str
Command line output of SoXI
'''
if argument not in SOXI_ARGS:
... | def soxi(filepath, argument):
''' Base call to SoXI.
Parameters
----------
filepath : str
Path to audio file.
argument : str
Argument to pass to SoXI.
Returns
-------
shell_output : str
Command line output of SoXI
'''
if argument not in SOXI_ARGS:
... | [
"Base",
"call",
"to",
"SoXI",
"."
] | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/core.py#L91-L126 | [
"def",
"soxi",
"(",
"filepath",
",",
"argument",
")",
":",
"if",
"argument",
"not",
"in",
"SOXI_ARGS",
":",
"raise",
"ValueError",
"(",
"\"Invalid argument '{}' to SoXI\"",
".",
"format",
"(",
"argument",
")",
")",
"args",
"=",
"[",
"'sox'",
",",
"'--i'",
... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | play | Pass an argument list to play.
Parameters
----------
args : iterable
Argument list for play. The first item can, but does not
need to, be 'play'.
Returns:
--------
status : bool
True on success. | sox/core.py | def play(args):
'''Pass an argument list to play.
Parameters
----------
args : iterable
Argument list for play. The first item can, but does not
need to, be 'play'.
Returns:
--------
status : bool
True on success.
'''
if args[0].lower() != "play":
a... | def play(args):
'''Pass an argument list to play.
Parameters
----------
args : iterable
Argument list for play. The first item can, but does not
need to, be 'play'.
Returns:
--------
status : bool
True on success.
'''
if args[0].lower() != "play":
a... | [
"Pass",
"an",
"argument",
"list",
"to",
"play",
"."
] | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/core.py#L129-L168 | [
"def",
"play",
"(",
"args",
")",
":",
"if",
"args",
"[",
"0",
"]",
".",
"lower",
"(",
")",
"!=",
"\"play\"",
":",
"args",
".",
"insert",
"(",
"0",
",",
"\"play\"",
")",
"else",
":",
"args",
"[",
"0",
"]",
"=",
"\"play\"",
"try",
":",
"logger",
... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | _validate_file_formats | Validate that combine method can be performed with given files.
Raises IOError if input file formats are incompatible. | sox/combine.py | def _validate_file_formats(input_filepath_list, combine_type):
'''Validate that combine method can be performed with given files.
Raises IOError if input file formats are incompatible.
'''
_validate_sample_rates(input_filepath_list, combine_type)
if combine_type == 'concatenate':
_validate_... | def _validate_file_formats(input_filepath_list, combine_type):
'''Validate that combine method can be performed with given files.
Raises IOError if input file formats are incompatible.
'''
_validate_sample_rates(input_filepath_list, combine_type)
if combine_type == 'concatenate':
_validate_... | [
"Validate",
"that",
"combine",
"method",
"can",
"be",
"performed",
"with",
"given",
"files",
".",
"Raises",
"IOError",
"if",
"input",
"file",
"formats",
"are",
"incompatible",
"."
] | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/combine.py#L308-L315 | [
"def",
"_validate_file_formats",
"(",
"input_filepath_list",
",",
"combine_type",
")",
":",
"_validate_sample_rates",
"(",
"input_filepath_list",
",",
"combine_type",
")",
"if",
"combine_type",
"==",
"'concatenate'",
":",
"_validate_num_channels",
"(",
"input_filepath_list"... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | _validate_sample_rates | Check if files in input file list have the same sample rate | sox/combine.py | def _validate_sample_rates(input_filepath_list, combine_type):
''' Check if files in input file list have the same sample rate
'''
sample_rates = [
file_info.sample_rate(f) for f in input_filepath_list
]
if not core.all_equal(sample_rates):
raise IOError(
"Input files do ... | def _validate_sample_rates(input_filepath_list, combine_type):
''' Check if files in input file list have the same sample rate
'''
sample_rates = [
file_info.sample_rate(f) for f in input_filepath_list
]
if not core.all_equal(sample_rates):
raise IOError(
"Input files do ... | [
"Check",
"if",
"files",
"in",
"input",
"file",
"list",
"have",
"the",
"same",
"sample",
"rate"
] | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/combine.py#L318-L329 | [
"def",
"_validate_sample_rates",
"(",
"input_filepath_list",
",",
"combine_type",
")",
":",
"sample_rates",
"=",
"[",
"file_info",
".",
"sample_rate",
"(",
"f",
")",
"for",
"f",
"in",
"input_filepath_list",
"]",
"if",
"not",
"core",
".",
"all_equal",
"(",
"sam... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | _validate_num_channels | Check if files in input file list have the same number of channels | sox/combine.py | def _validate_num_channels(input_filepath_list, combine_type):
''' Check if files in input file list have the same number of channels
'''
channels = [
file_info.channels(f) for f in input_filepath_list
]
if not core.all_equal(channels):
raise IOError(
"Input files do not ... | def _validate_num_channels(input_filepath_list, combine_type):
''' Check if files in input file list have the same number of channels
'''
channels = [
file_info.channels(f) for f in input_filepath_list
]
if not core.all_equal(channels):
raise IOError(
"Input files do not ... | [
"Check",
"if",
"files",
"in",
"input",
"file",
"list",
"have",
"the",
"same",
"number",
"of",
"channels"
] | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/combine.py#L332-L344 | [
"def",
"_validate_num_channels",
"(",
"input_filepath_list",
",",
"combine_type",
")",
":",
"channels",
"=",
"[",
"file_info",
".",
"channels",
"(",
"f",
")",
"for",
"f",
"in",
"input_filepath_list",
"]",
"if",
"not",
"core",
".",
"all_equal",
"(",
"channels",... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | _build_input_format_list | Set input formats given input_volumes.
Parameters
----------
input_filepath_list : list of str
List of input files
input_volumes : list of float, default=None
List of volumes to be applied upon combining input files. Volumes
are applied to the input files in order.
If No... | sox/combine.py | def _build_input_format_list(input_filepath_list, input_volumes=None,
input_format=None):
'''Set input formats given input_volumes.
Parameters
----------
input_filepath_list : list of str
List of input files
input_volumes : list of float, default=None
Li... | def _build_input_format_list(input_filepath_list, input_volumes=None,
input_format=None):
'''Set input formats given input_volumes.
Parameters
----------
input_filepath_list : list of str
List of input files
input_volumes : list of float, default=None
Li... | [
"Set",
"input",
"formats",
"given",
"input_volumes",
"."
] | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/combine.py#L347-L419 | [
"def",
"_build_input_format_list",
"(",
"input_filepath_list",
",",
"input_volumes",
"=",
"None",
",",
"input_format",
"=",
"None",
")",
":",
"n_inputs",
"=",
"len",
"(",
"input_filepath_list",
")",
"input_format_list",
"=",
"[",
"]",
"for",
"_",
"in",
"range",
... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | _build_input_args | Builds input arguments by stitching input filepaths and input
formats together. | sox/combine.py | def _build_input_args(input_filepath_list, input_format_list):
''' Builds input arguments by stitching input filepaths and input
formats together.
'''
if len(input_format_list) != len(input_filepath_list):
raise ValueError(
"input_format_list & input_filepath_list are not the same si... | def _build_input_args(input_filepath_list, input_format_list):
''' Builds input arguments by stitching input filepaths and input
formats together.
'''
if len(input_format_list) != len(input_filepath_list):
raise ValueError(
"input_format_list & input_filepath_list are not the same si... | [
"Builds",
"input",
"arguments",
"by",
"stitching",
"input",
"filepaths",
"and",
"input",
"formats",
"together",
"."
] | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/combine.py#L422-L437 | [
"def",
"_build_input_args",
"(",
"input_filepath_list",
",",
"input_format_list",
")",
":",
"if",
"len",
"(",
"input_format_list",
")",
"!=",
"len",
"(",
"input_filepath_list",
")",
":",
"raise",
"ValueError",
"(",
"\"input_format_list & input_filepath_list are not the sa... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | _validate_volumes | Check input_volumes contains a valid list of volumes.
Parameters
----------
input_volumes : list
list of volume values. Castable to numbers. | sox/combine.py | def _validate_volumes(input_volumes):
'''Check input_volumes contains a valid list of volumes.
Parameters
----------
input_volumes : list
list of volume values. Castable to numbers.
'''
if not (input_volumes is None or isinstance(input_volumes, list)):
raise TypeError("input_vo... | def _validate_volumes(input_volumes):
'''Check input_volumes contains a valid list of volumes.
Parameters
----------
input_volumes : list
list of volume values. Castable to numbers.
'''
if not (input_volumes is None or isinstance(input_volumes, list)):
raise TypeError("input_vo... | [
"Check",
"input_volumes",
"contains",
"a",
"valid",
"list",
"of",
"volumes",
"."
] | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/combine.py#L456-L474 | [
"def",
"_validate_volumes",
"(",
"input_volumes",
")",
":",
"if",
"not",
"(",
"input_volumes",
"is",
"None",
"or",
"isinstance",
"(",
"input_volumes",
",",
"list",
")",
")",
":",
"raise",
"TypeError",
"(",
"\"input_volumes must be None or a list.\"",
")",
"if",
... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | Combiner.build | Builds the output_file by executing the current set of commands.
Parameters
----------
input_filepath_list : list of str
List of paths to input audio files.
output_filepath : str
Path to desired output file. If a file already exists at the given
path,... | sox/combine.py | def build(self, input_filepath_list, output_filepath, combine_type,
input_volumes=None):
'''Builds the output_file by executing the current set of commands.
Parameters
----------
input_filepath_list : list of str
List of paths to input audio files.
outp... | def build(self, input_filepath_list, output_filepath, combine_type,
input_volumes=None):
'''Builds the output_file by executing the current set of commands.
Parameters
----------
input_filepath_list : list of str
List of paths to input audio files.
outp... | [
"Builds",
"the",
"output_file",
"by",
"executing",
"the",
"current",
"set",
"of",
"commands",
"."
] | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/combine.py#L40-L110 | [
"def",
"build",
"(",
"self",
",",
"input_filepath_list",
",",
"output_filepath",
",",
"combine_type",
",",
"input_volumes",
"=",
"None",
")",
":",
"file_info",
".",
"validate_input_file_list",
"(",
"input_filepath_list",
")",
"file_info",
".",
"validate_output_file",
... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | Combiner.preview | Play a preview of the output with the current set of effects
Parameters
----------
input_filepath_list : list of str
List of paths to input audio files.
combine_type : str
Input file combining method. One of the following values:
* concatenate : c... | sox/combine.py | def preview(self, input_filepath_list, combine_type, input_volumes=None):
'''Play a preview of the output with the current set of effects
Parameters
----------
input_filepath_list : list of str
List of paths to input audio files.
combine_type : str
Input ... | def preview(self, input_filepath_list, combine_type, input_volumes=None):
'''Play a preview of the output with the current set of effects
Parameters
----------
input_filepath_list : list of str
List of paths to input audio files.
combine_type : str
Input ... | [
"Play",
"a",
"preview",
"of",
"the",
"output",
"with",
"the",
"current",
"set",
"of",
"effects"
] | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/combine.py#L112-L149 | [
"def",
"preview",
"(",
"self",
",",
"input_filepath_list",
",",
"combine_type",
",",
"input_volumes",
"=",
"None",
")",
":",
"args",
"=",
"[",
"\"play\"",
",",
"\"--no-show-progress\"",
"]",
"args",
".",
"extend",
"(",
"self",
".",
"globals",
")",
"args",
... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | Combiner.set_input_format | Sets input file format arguments. This is primarily useful when
dealing with audio files without a file extension. Overwrites any
previously set input file arguments.
If this function is not explicity called the input format is inferred
from the file extension or the file's header.
... | sox/combine.py | def set_input_format(self, file_type=None, rate=None, bits=None,
channels=None, encoding=None, ignore_length=None):
'''Sets input file format arguments. This is primarily useful when
dealing with audio files without a file extension. Overwrites any
previously set input f... | def set_input_format(self, file_type=None, rate=None, bits=None,
channels=None, encoding=None, ignore_length=None):
'''Sets input file format arguments. This is primarily useful when
dealing with audio files without a file extension. Overwrites any
previously set input f... | [
"Sets",
"input",
"file",
"format",
"arguments",
".",
"This",
"is",
"primarily",
"useful",
"when",
"dealing",
"with",
"audio",
"files",
"without",
"a",
"file",
"extension",
".",
"Overwrites",
"any",
"previously",
"set",
"input",
"file",
"arguments",
"."
] | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/combine.py#L151-L305 | [
"def",
"set_input_format",
"(",
"self",
",",
"file_type",
"=",
"None",
",",
"rate",
"=",
"None",
",",
"bits",
"=",
"None",
",",
"channels",
"=",
"None",
",",
"encoding",
"=",
"None",
",",
"ignore_length",
"=",
"None",
")",
":",
"if",
"file_type",
"is",... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | bitrate | Number of bits per sample (0 if not applicable).
Parameters
----------
input_filepath : str
Path to audio file.
Returns
-------
bitrate : int
number of bits per sample
returns 0 if not applicable | sox/file_info.py | def bitrate(input_filepath):
'''
Number of bits per sample (0 if not applicable).
Parameters
----------
input_filepath : str
Path to audio file.
Returns
-------
bitrate : int
number of bits per sample
returns 0 if not applicable
'''
validate_input_file(i... | def bitrate(input_filepath):
'''
Number of bits per sample (0 if not applicable).
Parameters
----------
input_filepath : str
Path to audio file.
Returns
-------
bitrate : int
number of bits per sample
returns 0 if not applicable
'''
validate_input_file(i... | [
"Number",
"of",
"bits",
"per",
"sample",
"(",
"0",
"if",
"not",
"applicable",
")",
"."
] | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/file_info.py#L12-L31 | [
"def",
"bitrate",
"(",
"input_filepath",
")",
":",
"validate_input_file",
"(",
"input_filepath",
")",
"output",
"=",
"soxi",
"(",
"input_filepath",
",",
"'b'",
")",
"if",
"output",
"==",
"'0'",
":",
"logger",
".",
"warning",
"(",
"\"Bitrate unavailable for %s\""... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | duration | Show duration in seconds (0 if unavailable).
Parameters
----------
input_filepath : str
Path to audio file.
Returns
-------
duration : float
Duration of audio file in seconds.
If unavailable or empty, returns 0. | sox/file_info.py | def duration(input_filepath):
'''
Show duration in seconds (0 if unavailable).
Parameters
----------
input_filepath : str
Path to audio file.
Returns
-------
duration : float
Duration of audio file in seconds.
If unavailable or empty, returns 0.
'''
vali... | def duration(input_filepath):
'''
Show duration in seconds (0 if unavailable).
Parameters
----------
input_filepath : str
Path to audio file.
Returns
-------
duration : float
Duration of audio file in seconds.
If unavailable or empty, returns 0.
'''
vali... | [
"Show",
"duration",
"in",
"seconds",
"(",
"0",
"if",
"unavailable",
")",
"."
] | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/file_info.py#L73-L93 | [
"def",
"duration",
"(",
"input_filepath",
")",
":",
"validate_input_file",
"(",
"input_filepath",
")",
"output",
"=",
"soxi",
"(",
"input_filepath",
",",
"'D'",
")",
"if",
"output",
"==",
"'0'",
":",
"logger",
".",
"warning",
"(",
"\"Duration unavailable for %s\... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | num_samples | Show number of samples (0 if unavailable).
Parameters
----------
input_filepath : str
Path to audio file.
Returns
-------
n_samples : int
total number of samples in audio file.
Returns 0 if empty or unavailable | sox/file_info.py | def num_samples(input_filepath):
'''
Show number of samples (0 if unavailable).
Parameters
----------
input_filepath : str
Path to audio file.
Returns
-------
n_samples : int
total number of samples in audio file.
Returns 0 if empty or unavailable
'''
va... | def num_samples(input_filepath):
'''
Show number of samples (0 if unavailable).
Parameters
----------
input_filepath : str
Path to audio file.
Returns
-------
n_samples : int
total number of samples in audio file.
Returns 0 if empty or unavailable
'''
va... | [
"Show",
"number",
"of",
"samples",
"(",
"0",
"if",
"unavailable",
")",
"."
] | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/file_info.py#L134-L153 | [
"def",
"num_samples",
"(",
"input_filepath",
")",
":",
"validate_input_file",
"(",
"input_filepath",
")",
"output",
"=",
"soxi",
"(",
"input_filepath",
",",
"'s'",
")",
"if",
"output",
"==",
"'0'",
":",
"logger",
".",
"warning",
"(",
"\"Number of samples unavail... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | silent | Determine if an input file is silent.
Parameters
----------
input_filepath : str
The input filepath.
threshold : float
Threshold for determining silence
Returns
-------
is_silent : bool
True if file is determined silent. | sox/file_info.py | def silent(input_filepath, threshold=0.001):
'''
Determine if an input file is silent.
Parameters
----------
input_filepath : str
The input filepath.
threshold : float
Threshold for determining silence
Returns
-------
is_silent : bool
True if file is determi... | def silent(input_filepath, threshold=0.001):
'''
Determine if an input file is silent.
Parameters
----------
input_filepath : str
The input filepath.
threshold : float
Threshold for determining silence
Returns
-------
is_silent : bool
True if file is determi... | [
"Determine",
"if",
"an",
"input",
"file",
"is",
"silent",
"."
] | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/file_info.py#L175-L200 | [
"def",
"silent",
"(",
"input_filepath",
",",
"threshold",
"=",
"0.001",
")",
":",
"validate_input_file",
"(",
"input_filepath",
")",
"stat_dictionary",
"=",
"stat",
"(",
"input_filepath",
")",
"mean_norm",
"=",
"stat_dictionary",
"[",
"'Mean norm'",
"]",
"if",
... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | validate_input_file | Input file validation function. Checks that file exists and can be
processed by SoX.
Parameters
----------
input_filepath : str
The input filepath. | sox/file_info.py | def validate_input_file(input_filepath):
'''Input file validation function. Checks that file exists and can be
processed by SoX.
Parameters
----------
input_filepath : str
The input filepath.
'''
if not os.path.exists(input_filepath):
raise IOError(
"input_filep... | def validate_input_file(input_filepath):
'''Input file validation function. Checks that file exists and can be
processed by SoX.
Parameters
----------
input_filepath : str
The input filepath.
'''
if not os.path.exists(input_filepath):
raise IOError(
"input_filep... | [
"Input",
"file",
"validation",
"function",
".",
"Checks",
"that",
"file",
"exists",
"and",
"can",
"be",
"processed",
"by",
"SoX",
"."
] | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/file_info.py#L203-L222 | [
"def",
"validate_input_file",
"(",
"input_filepath",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"input_filepath",
")",
":",
"raise",
"IOError",
"(",
"\"input_filepath {} does not exist.\"",
".",
"format",
"(",
"input_filepath",
")",
")",
"ext"... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | validate_input_file_list | Input file list validation function. Checks that object is a list and
contains valid filepaths that can be processed by SoX.
Parameters
----------
input_filepath_list : list
A list of filepaths. | sox/file_info.py | def validate_input_file_list(input_filepath_list):
'''Input file list validation function. Checks that object is a list and
contains valid filepaths that can be processed by SoX.
Parameters
----------
input_filepath_list : list
A list of filepaths.
'''
if not isinstance(input_filep... | def validate_input_file_list(input_filepath_list):
'''Input file list validation function. Checks that object is a list and
contains valid filepaths that can be processed by SoX.
Parameters
----------
input_filepath_list : list
A list of filepaths.
'''
if not isinstance(input_filep... | [
"Input",
"file",
"list",
"validation",
"function",
".",
"Checks",
"that",
"object",
"is",
"a",
"list",
"and",
"contains",
"valid",
"filepaths",
"that",
"can",
"be",
"processed",
"by",
"SoX",
"."
] | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/file_info.py#L225-L241 | [
"def",
"validate_input_file_list",
"(",
"input_filepath_list",
")",
":",
"if",
"not",
"isinstance",
"(",
"input_filepath_list",
",",
"list",
")",
":",
"raise",
"TypeError",
"(",
"\"input_filepath_list must be a list.\"",
")",
"elif",
"len",
"(",
"input_filepath_list",
... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | validate_output_file | Output file validation function. Checks that file can be written, and
has a valid file extension. Throws a warning if the path already exists,
as it will be overwritten on build.
Parameters
----------
output_filepath : str
The output filepath.
Returns:
--------
output_filepath ... | sox/file_info.py | def validate_output_file(output_filepath):
'''Output file validation function. Checks that file can be written, and
has a valid file extension. Throws a warning if the path already exists,
as it will be overwritten on build.
Parameters
----------
output_filepath : str
The output filepat... | def validate_output_file(output_filepath):
'''Output file validation function. Checks that file can be written, and
has a valid file extension. Throws a warning if the path already exists,
as it will be overwritten on build.
Parameters
----------
output_filepath : str
The output filepat... | [
"Output",
"file",
"validation",
"function",
".",
"Checks",
"that",
"file",
"can",
"be",
"written",
"and",
"has",
"a",
"valid",
"file",
"extension",
".",
"Throws",
"a",
"warning",
"if",
"the",
"path",
"already",
"exists",
"as",
"it",
"will",
"be",
"overwrit... | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/file_info.py#L244-L282 | [
"def",
"validate_output_file",
"(",
"output_filepath",
")",
":",
"nowrite_conditions",
"=",
"[",
"bool",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"output_filepath",
")",
")",
"or",
"not",
"os",
".",
"access",
"(",
"os",
".",
"getcwd",
"(",
")",
",",
... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | info | Get a dictionary of file information
Parameters
----------
filepath : str
File path.
Returns:
--------
info_dictionary : dict
Dictionary of file information. Fields are:
* channels
* sample_rate
* bitrate
* duration
* ... | sox/file_info.py | def info(filepath):
'''Get a dictionary of file information
Parameters
----------
filepath : str
File path.
Returns:
--------
info_dictionary : dict
Dictionary of file information. Fields are:
* channels
* sample_rate
* bitrate
... | def info(filepath):
'''Get a dictionary of file information
Parameters
----------
filepath : str
File path.
Returns:
--------
info_dictionary : dict
Dictionary of file information. Fields are:
* channels
* sample_rate
* bitrate
... | [
"Get",
"a",
"dictionary",
"of",
"file",
"information"
] | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/file_info.py#L301-L330 | [
"def",
"info",
"(",
"filepath",
")",
":",
"info_dictionary",
"=",
"{",
"'channels'",
":",
"channels",
"(",
"filepath",
")",
",",
"'sample_rate'",
":",
"sample_rate",
"(",
"filepath",
")",
",",
"'bitrate'",
":",
"bitrate",
"(",
"filepath",
")",
",",
"'durat... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | _stat_call | Call sox's stat function.
Parameters
----------
filepath : str
File path.
Returns
-------
stat_output : str
Sox output from stderr. | sox/file_info.py | def _stat_call(filepath):
'''Call sox's stat function.
Parameters
----------
filepath : str
File path.
Returns
-------
stat_output : str
Sox output from stderr.
'''
validate_input_file(filepath)
args = ['sox', filepath, '-n', 'stat']
_, _, stat_output = sox(... | def _stat_call(filepath):
'''Call sox's stat function.
Parameters
----------
filepath : str
File path.
Returns
-------
stat_output : str
Sox output from stderr.
'''
validate_input_file(filepath)
args = ['sox', filepath, '-n', 'stat']
_, _, stat_output = sox(... | [
"Call",
"sox",
"s",
"stat",
"function",
"."
] | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/file_info.py#L351-L367 | [
"def",
"_stat_call",
"(",
"filepath",
")",
":",
"validate_input_file",
"(",
"filepath",
")",
"args",
"=",
"[",
"'sox'",
",",
"filepath",
",",
"'-n'",
",",
"'stat'",
"]",
"_",
",",
"_",
",",
"stat_output",
"=",
"sox",
"(",
"args",
")",
"return",
"stat_o... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | _parse_stat | Parse the string output from sox's stat function
Parameters
----------
stat_output : str
Sox output from stderr.
Returns
-------
stat_dictionary : dict
Dictionary of audio statistics. | sox/file_info.py | def _parse_stat(stat_output):
'''Parse the string output from sox's stat function
Parameters
----------
stat_output : str
Sox output from stderr.
Returns
-------
stat_dictionary : dict
Dictionary of audio statistics.
'''
lines = stat_output.split('\n')
stat_dict... | def _parse_stat(stat_output):
'''Parse the string output from sox's stat function
Parameters
----------
stat_output : str
Sox output from stderr.
Returns
-------
stat_dictionary : dict
Dictionary of audio statistics.
'''
lines = stat_output.split('\n')
stat_dict... | [
"Parse",
"the",
"string",
"output",
"from",
"sox",
"s",
"stat",
"function"
] | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/file_info.py#L370-L396 | [
"def",
"_parse_stat",
"(",
"stat_output",
")",
":",
"lines",
"=",
"stat_output",
".",
"split",
"(",
"'\\n'",
")",
"stat_dict",
"=",
"{",
"}",
"for",
"line",
"in",
"lines",
":",
"split_line",
"=",
"line",
".",
"split",
"(",
"':'",
")",
"if",
"len",
"(... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | Transformer.set_globals | Sets SoX's global arguments.
Overwrites any previously set global arguments.
If this function is not explicity called, globals are set to this
function's defaults.
Parameters
----------
dither : bool, default=False
If True, dithering is applied for low files ... | sox/transform.py | def set_globals(self, dither=False, guard=False, multithread=False,
replay_gain=False, verbosity=2):
'''Sets SoX's global arguments.
Overwrites any previously set global arguments.
If this function is not explicity called, globals are set to this
function's defaults.
... | def set_globals(self, dither=False, guard=False, multithread=False,
replay_gain=False, verbosity=2):
'''Sets SoX's global arguments.
Overwrites any previously set global arguments.
If this function is not explicity called, globals are set to this
function's defaults.
... | [
"Sets",
"SoX",
"s",
"global",
"arguments",
".",
"Overwrites",
"any",
"previously",
"set",
"global",
"arguments",
".",
"If",
"this",
"function",
"is",
"not",
"explicity",
"called",
"globals",
"are",
"set",
"to",
"this",
"function",
"s",
"defaults",
"."
] | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/transform.py#L67-L134 | [
"def",
"set_globals",
"(",
"self",
",",
"dither",
"=",
"False",
",",
"guard",
"=",
"False",
",",
"multithread",
"=",
"False",
",",
"replay_gain",
"=",
"False",
",",
"verbosity",
"=",
"2",
")",
":",
"if",
"not",
"isinstance",
"(",
"dither",
",",
"bool",... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | Transformer.set_input_format | Sets input file format arguments. This is primarily useful when
dealing with audio files without a file extension. Overwrites any
previously set input file arguments.
If this function is not explicity called the input format is inferred
from the file extension or the file's header.
... | sox/transform.py | def set_input_format(self, file_type=None, rate=None, bits=None,
channels=None, encoding=None, ignore_length=False):
'''Sets input file format arguments. This is primarily useful when
dealing with audio files without a file extension. Overwrites any
previously set input ... | def set_input_format(self, file_type=None, rate=None, bits=None,
channels=None, encoding=None, ignore_length=False):
'''Sets input file format arguments. This is primarily useful when
dealing with audio files without a file extension. Overwrites any
previously set input ... | [
"Sets",
"input",
"file",
"format",
"arguments",
".",
"This",
"is",
"primarily",
"useful",
"when",
"dealing",
"with",
"audio",
"files",
"without",
"a",
"file",
"extension",
".",
"Overwrites",
"any",
"previously",
"set",
"input",
"file",
"arguments",
"."
] | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/transform.py#L136-L253 | [
"def",
"set_input_format",
"(",
"self",
",",
"file_type",
"=",
"None",
",",
"rate",
"=",
"None",
",",
"bits",
"=",
"None",
",",
"channels",
"=",
"None",
",",
"encoding",
"=",
"None",
",",
"ignore_length",
"=",
"False",
")",
":",
"if",
"file_type",
"not... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | Transformer.set_output_format | Sets output file format arguments. These arguments will overwrite
any format related arguments supplied by other effects (e.g. rate).
If this function is not explicity called the output format is inferred
from the file extension or the file's header.
Parameters
----------
... | sox/transform.py | def set_output_format(self, file_type=None, rate=None, bits=None,
channels=None, encoding=None, comments=None,
append_comments=True):
'''Sets output file format arguments. These arguments will overwrite
any format related arguments supplied by other ef... | def set_output_format(self, file_type=None, rate=None, bits=None,
channels=None, encoding=None, comments=None,
append_comments=True):
'''Sets output file format arguments. These arguments will overwrite
any format related arguments supplied by other ef... | [
"Sets",
"output",
"file",
"format",
"arguments",
".",
"These",
"arguments",
"will",
"overwrite",
"any",
"format",
"related",
"arguments",
"supplied",
"by",
"other",
"effects",
"(",
"e",
".",
"g",
".",
"rate",
")",
"."
] | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/transform.py#L255-L380 | [
"def",
"set_output_format",
"(",
"self",
",",
"file_type",
"=",
"None",
",",
"rate",
"=",
"None",
",",
"bits",
"=",
"None",
",",
"channels",
"=",
"None",
",",
"encoding",
"=",
"None",
",",
"comments",
"=",
"None",
",",
"append_comments",
"=",
"True",
"... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | Transformer.build | Builds the output_file by executing the current set of commands.
Parameters
----------
input_filepath : str
Path to input audio file.
output_filepath : str or None
Path to desired output file. If a file already exists at the given
path, the file will ... | sox/transform.py | def build(self, input_filepath, output_filepath, extra_args=None,
return_output=False):
'''Builds the output_file by executing the current set of commands.
Parameters
----------
input_filepath : str
Path to input audio file.
output_filepath : str or Non... | def build(self, input_filepath, output_filepath, extra_args=None,
return_output=False):
'''Builds the output_file by executing the current set of commands.
Parameters
----------
input_filepath : str
Path to input audio file.
output_filepath : str or Non... | [
"Builds",
"the",
"output_file",
"by",
"executing",
"the",
"current",
"set",
"of",
"commands",
"."
] | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/transform.py#L390-L455 | [
"def",
"build",
"(",
"self",
",",
"input_filepath",
",",
"output_filepath",
",",
"extra_args",
"=",
"None",
",",
"return_output",
"=",
"False",
")",
":",
"file_info",
".",
"validate_input_file",
"(",
"input_filepath",
")",
"if",
"output_filepath",
"is",
"not",
... | eae89bde74567136ec3f723c3e6b369916d9b837 |
valid | Transformer.preview | Play a preview of the output with the current set of effects
Parameters
----------
input_filepath : str
Path to input audio file. | sox/transform.py | def preview(self, input_filepath):
'''Play a preview of the output with the current set of effects
Parameters
----------
input_filepath : str
Path to input audio file.
'''
args = ["play", "--no-show-progress"]
args.extend(self.globals)
args.e... | def preview(self, input_filepath):
'''Play a preview of the output with the current set of effects
Parameters
----------
input_filepath : str
Path to input audio file.
'''
args = ["play", "--no-show-progress"]
args.extend(self.globals)
args.e... | [
"Play",
"a",
"preview",
"of",
"the",
"output",
"with",
"the",
"current",
"set",
"of",
"effects"
] | rabitt/pysox | python | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/transform.py#L457-L472 | [
"def",
"preview",
"(",
"self",
",",
"input_filepath",
")",
":",
"args",
"=",
"[",
"\"play\"",
",",
"\"--no-show-progress\"",
"]",
"args",
".",
"extend",
"(",
"self",
".",
"globals",
")",
"args",
".",
"extend",
"(",
"self",
".",
"input_format",
")",
"args... | eae89bde74567136ec3f723c3e6b369916d9b837 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.