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
_getCallingContext
Utility function for the RedisLogRecord. Returns the module, function, and lineno of the function that called the logger. We look way up in the stack. The stack at this point is: [0] logger.py _getCallingContext (hey, that's me!) [1] logger.py __init__ [2] logger.py makeRecord [3] _lo...
redislog/logger.py
def _getCallingContext(): """ Utility function for the RedisLogRecord. Returns the module, function, and lineno of the function that called the logger. We look way up in the stack. The stack at this point is: [0] logger.py _getCallingContext (hey, that's me!) [1] logger.py __init__ ...
def _getCallingContext(): """ Utility function for the RedisLogRecord. Returns the module, function, and lineno of the function that called the logger. We look way up in the stack. The stack at this point is: [0] logger.py _getCallingContext (hey, that's me!) [1] logger.py __init__ ...
[ "Utility", "function", "for", "the", "RedisLogRecord", "." ]
jedp/python-redis-log
python
https://github.com/jedp/python-redis-log/blob/3fc81a43423adf289a7ec985f282a8a40341fc87/redislog/logger.py#L15-L50
[ "def", "_getCallingContext", "(", ")", ":", "frames", "=", "inspect", ".", "stack", "(", ")", "if", "len", "(", "frames", ")", ">", "4", ":", "context", "=", "frames", "[", "5", "]", "else", ":", "context", "=", "frames", "[", "0", "]", "modname", ...
3fc81a43423adf289a7ec985f282a8a40341fc87
valid
RedisFormatter.format
JSON-encode a record for serializing through redis. Convert date to iso format, and stringify any exceptions.
redislog/handlers.py
def format(self, record): """ JSON-encode a record for serializing through redis. Convert date to iso format, and stringify any exceptions. """ data = record._raw.copy() # serialize the datetime date as utc string data['time'] = data['time'].isoformat() ...
def format(self, record): """ JSON-encode a record for serializing through redis. Convert date to iso format, and stringify any exceptions. """ data = record._raw.copy() # serialize the datetime date as utc string data['time'] = data['time'].isoformat() ...
[ "JSON", "-", "encode", "a", "record", "for", "serializing", "through", "redis", "." ]
jedp/python-redis-log
python
https://github.com/jedp/python-redis-log/blob/3fc81a43423adf289a7ec985f282a8a40341fc87/redislog/handlers.py#L7-L22
[ "def", "format", "(", "self", ",", "record", ")", ":", "data", "=", "record", ".", "_raw", ".", "copy", "(", ")", "# serialize the datetime date as utc string", "data", "[", "'time'", "]", "=", "data", "[", "'time'", "]", ".", "isoformat", "(", ")", "# s...
3fc81a43423adf289a7ec985f282a8a40341fc87
valid
RedisHandler.emit
Publish record to redis logging channel
redislog/handlers.py
def emit(self, record): """ Publish record to redis logging channel """ try: self.redis_client.publish(self.channel, self.format(record)) except redis.RedisError: pass
def emit(self, record): """ Publish record to redis logging channel """ try: self.redis_client.publish(self.channel, self.format(record)) except redis.RedisError: pass
[ "Publish", "record", "to", "redis", "logging", "channel" ]
jedp/python-redis-log
python
https://github.com/jedp/python-redis-log/blob/3fc81a43423adf289a7ec985f282a8a40341fc87/redislog/handlers.py#L46-L53
[ "def", "emit", "(", "self", ",", "record", ")", ":", "try", ":", "self", ".", "redis_client", ".", "publish", "(", "self", ".", "channel", ",", "self", ".", "format", "(", "record", ")", ")", "except", "redis", ".", "RedisError", ":", "pass" ]
3fc81a43423adf289a7ec985f282a8a40341fc87
valid
RedisListHandler.emit
Publish record to redis logging list
redislog/handlers.py
def emit(self, record): """ Publish record to redis logging list """ try: if self.max_messages: p = self.redis_client.pipeline() p.rpush(self.key, self.format(record)) p.ltrim(self.key, -self.max_messages, -1) p....
def emit(self, record): """ Publish record to redis logging list """ try: if self.max_messages: p = self.redis_client.pipeline() p.rpush(self.key, self.format(record)) p.ltrim(self.key, -self.max_messages, -1) p....
[ "Publish", "record", "to", "redis", "logging", "list" ]
jedp/python-redis-log
python
https://github.com/jedp/python-redis-log/blob/3fc81a43423adf289a7ec985f282a8a40341fc87/redislog/handlers.py#L80-L93
[ "def", "emit", "(", "self", ",", "record", ")", ":", "try", ":", "if", "self", ".", "max_messages", ":", "p", "=", "self", ".", "redis_client", ".", "pipeline", "(", ")", "p", ".", "rpush", "(", "self", ".", "key", ",", "self", ".", "format", "("...
3fc81a43423adf289a7ec985f282a8a40341fc87
valid
require_template_debug
Decorated function is a no-op if TEMPLATE_DEBUG is False
template_debug/templatetags/debug_tags.py
def require_template_debug(f): """Decorated function is a no-op if TEMPLATE_DEBUG is False""" def _(*args, **kwargs): TEMPLATE_DEBUG = getattr(settings, 'TEMPLATE_DEBUG', False) return f(*args, **kwargs) if TEMPLATE_DEBUG else '' return _
def require_template_debug(f): """Decorated function is a no-op if TEMPLATE_DEBUG is False""" def _(*args, **kwargs): TEMPLATE_DEBUG = getattr(settings, 'TEMPLATE_DEBUG', False) return f(*args, **kwargs) if TEMPLATE_DEBUG else '' return _
[ "Decorated", "function", "is", "a", "no", "-", "op", "if", "TEMPLATE_DEBUG", "is", "False" ]
calebsmith/django-template-debug
python
https://github.com/calebsmith/django-template-debug/blob/f3d52638da571164d63e5c8331d409b0743c628f/template_debug/templatetags/debug_tags.py#L18-L23
[ "def", "require_template_debug", "(", "f", ")", ":", "def", "_", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "TEMPLATE_DEBUG", "=", "getattr", "(", "settings", ",", "'TEMPLATE_DEBUG'", ",", "False", ")", "return", "f", "(", "*", "args", ",", ...
f3d52638da571164d63e5c8331d409b0743c628f
valid
_display_details
Given a dictionary of variable attribute data from get_details display the data in the terminal.
template_debug/templatetags/debug_tags.py
def _display_details(var_data): """ Given a dictionary of variable attribute data from get_details display the data in the terminal. """ meta_keys = (key for key in list(var_data.keys()) if key.startswith('META_')) for key in meta_keys: display_key = key[5:].capitalize()...
def _display_details(var_data): """ Given a dictionary of variable attribute data from get_details display the data in the terminal. """ meta_keys = (key for key in list(var_data.keys()) if key.startswith('META_')) for key in meta_keys: display_key = key[5:].capitalize()...
[ "Given", "a", "dictionary", "of", "variable", "attribute", "data", "from", "get_details", "display", "the", "data", "in", "the", "terminal", "." ]
calebsmith/django-template-debug
python
https://github.com/calebsmith/django-template-debug/blob/f3d52638da571164d63e5c8331d409b0743c628f/template_debug/templatetags/debug_tags.py#L26-L36
[ "def", "_display_details", "(", "var_data", ")", ":", "meta_keys", "=", "(", "key", "for", "key", "in", "list", "(", "var_data", ".", "keys", "(", ")", ")", "if", "key", ".", "startswith", "(", "'META_'", ")", ")", "for", "key", "in", "meta_keys", ":...
f3d52638da571164d63e5c8331d409b0743c628f
valid
set_trace
Start a pdb set_trace inside of the template with the context available as 'context'. Uses ipdb if available.
template_debug/templatetags/debug_tags.py
def set_trace(context): """ Start a pdb set_trace inside of the template with the context available as 'context'. Uses ipdb if available. """ try: import ipdb as pdb except ImportError: import pdb print("For best results, pip install ipdb.") print("Variables that are ...
def set_trace(context): """ Start a pdb set_trace inside of the template with the context available as 'context'. Uses ipdb if available. """ try: import ipdb as pdb except ImportError: import pdb print("For best results, pip install ipdb.") print("Variables that are ...
[ "Start", "a", "pdb", "set_trace", "inside", "of", "the", "template", "with", "the", "context", "available", "as", "context", ".", "Uses", "ipdb", "if", "available", "." ]
calebsmith/django-template-debug
python
https://github.com/calebsmith/django-template-debug/blob/f3d52638da571164d63e5c8331d409b0743c628f/template_debug/templatetags/debug_tags.py#L77-L98
[ "def", "set_trace", "(", "context", ")", ":", "try", ":", "import", "ipdb", "as", "pdb", "except", "ImportError", ":", "import", "pdb", "print", "(", "\"For best results, pip install ipdb.\"", ")", "print", "(", "\"Variables that are available in the current context:\""...
f3d52638da571164d63e5c8331d409b0743c628f
valid
pydevd
Start a pydev settrace
template_debug/templatetags/debug_tags.py
def pydevd(context): """ Start a pydev settrace """ global pdevd_not_available if pdevd_not_available: return '' try: import pydevd except ImportError: pdevd_not_available = True return '' render = lambda s: template.Template(s).render(context) availab...
def pydevd(context): """ Start a pydev settrace """ global pdevd_not_available if pdevd_not_available: return '' try: import pydevd except ImportError: pdevd_not_available = True return '' render = lambda s: template.Template(s).render(context) availab...
[ "Start", "a", "pydev", "settrace" ]
calebsmith/django-template-debug
python
https://github.com/calebsmith/django-template-debug/blob/f3d52638da571164d63e5c8331d409b0743c628f/template_debug/templatetags/debug_tags.py#L107-L128
[ "def", "pydevd", "(", "context", ")", ":", "global", "pdevd_not_available", "if", "pdevd_not_available", ":", "return", "''", "try", ":", "import", "pydevd", "except", "ImportError", ":", "pdevd_not_available", "=", "True", "return", "''", "render", "=", "lambda...
f3d52638da571164d63e5c8331d409b0743c628f
valid
_flatten
Given an iterable with nested iterables, generate a flat iterable
template_debug/utils.py
def _flatten(iterable): """ Given an iterable with nested iterables, generate a flat iterable """ for i in iterable: if isinstance(i, Iterable) and not isinstance(i, string_types): for sub_i in _flatten(i): yield sub_i else: yield i
def _flatten(iterable): """ Given an iterable with nested iterables, generate a flat iterable """ for i in iterable: if isinstance(i, Iterable) and not isinstance(i, string_types): for sub_i in _flatten(i): yield sub_i else: yield i
[ "Given", "an", "iterable", "with", "nested", "iterables", "generate", "a", "flat", "iterable" ]
calebsmith/django-template-debug
python
https://github.com/calebsmith/django-template-debug/blob/f3d52638da571164d63e5c8331d409b0743c628f/template_debug/utils.py#L15-L24
[ "def", "_flatten", "(", "iterable", ")", ":", "for", "i", "in", "iterable", ":", "if", "isinstance", "(", "i", ",", "Iterable", ")", "and", "not", "isinstance", "(", "i", ",", "string_types", ")", ":", "for", "sub_i", "in", "_flatten", "(", "i", ")",...
f3d52638da571164d63e5c8331d409b0743c628f
valid
get_details
Given a variable inside the context, obtain the attributes/callables, their values where possible, and the module name and class name if possible
template_debug/utils.py
def get_details(var): """ Given a variable inside the context, obtain the attributes/callables, their values where possible, and the module name and class name if possible """ var_data = {} # Obtain module and class details if available and add them in module = getattr(var, '__module__', '')...
def get_details(var): """ Given a variable inside the context, obtain the attributes/callables, their values where possible, and the module name and class name if possible """ var_data = {} # Obtain module and class details if available and add them in module = getattr(var, '__module__', '')...
[ "Given", "a", "variable", "inside", "the", "context", "obtain", "the", "attributes", "/", "callables", "their", "values", "where", "possible", "and", "the", "module", "name", "and", "class", "name", "if", "possible" ]
calebsmith/django-template-debug
python
https://github.com/calebsmith/django-template-debug/blob/f3d52638da571164d63e5c8331d409b0743c628f/template_debug/utils.py#L34-L51
[ "def", "get_details", "(", "var", ")", ":", "var_data", "=", "{", "}", "# Obtain module and class details if available and add them in", "module", "=", "getattr", "(", "var", ",", "'__module__'", ",", "''", ")", "kls", "=", "getattr", "(", "getattr", "(", "var",...
f3d52638da571164d63e5c8331d409b0743c628f
valid
_get_detail_value
Given a variable and one of its attributes that are available inside of a template, return its 'method' if it is a callable, its class name if it is a model manager, otherwise return its value
template_debug/utils.py
def _get_detail_value(var, attr): """ Given a variable and one of its attributes that are available inside of a template, return its 'method' if it is a callable, its class name if it is a model manager, otherwise return its value """ value = getattr(var, attr) # Rename common Django class n...
def _get_detail_value(var, attr): """ Given a variable and one of its attributes that are available inside of a template, return its 'method' if it is a callable, its class name if it is a model manager, otherwise return its value """ value = getattr(var, attr) # Rename common Django class n...
[ "Given", "a", "variable", "and", "one", "of", "its", "attributes", "that", "are", "available", "inside", "of", "a", "template", "return", "its", "method", "if", "it", "is", "a", "callable", "its", "class", "name", "if", "it", "is", "a", "model", "manager...
calebsmith/django-template-debug
python
https://github.com/calebsmith/django-template-debug/blob/f3d52638da571164d63e5c8331d409b0743c628f/template_debug/utils.py#L54-L67
[ "def", "_get_detail_value", "(", "var", ",", "attr", ")", ":", "value", "=", "getattr", "(", "var", ",", "attr", ")", "# Rename common Django class names", "kls", "=", "getattr", "(", "getattr", "(", "value", ",", "'__class__'", ",", "''", ")", ",", "'__na...
f3d52638da571164d63e5c8331d409b0743c628f
valid
get_attributes
Given a varaible, return the list of attributes that are available inside of a template
template_debug/utils.py
def get_attributes(var): """ Given a varaible, return the list of attributes that are available inside of a template """ is_valid = partial(is_valid_in_template, var) return list(filter(is_valid, dir(var)))
def get_attributes(var): """ Given a varaible, return the list of attributes that are available inside of a template """ is_valid = partial(is_valid_in_template, var) return list(filter(is_valid, dir(var)))
[ "Given", "a", "varaible", "return", "the", "list", "of", "attributes", "that", "are", "available", "inside", "of", "a", "template" ]
calebsmith/django-template-debug
python
https://github.com/calebsmith/django-template-debug/blob/f3d52638da571164d63e5c8331d409b0743c628f/template_debug/utils.py#L70-L76
[ "def", "get_attributes", "(", "var", ")", ":", "is_valid", "=", "partial", "(", "is_valid_in_template", ",", "var", ")", "return", "list", "(", "filter", "(", "is_valid", ",", "dir", "(", "var", ")", ")", ")" ]
f3d52638da571164d63e5c8331d409b0743c628f
valid
is_valid_in_template
Given a variable and one of its attributes, determine if the attribute is accessible inside of a Django template and return True or False accordingly
template_debug/utils.py
def is_valid_in_template(var, attr): """ Given a variable and one of its attributes, determine if the attribute is accessible inside of a Django template and return True or False accordingly """ # Remove private variables or methods if attr.startswith('_'): return False # Remove any ...
def is_valid_in_template(var, attr): """ Given a variable and one of its attributes, determine if the attribute is accessible inside of a Django template and return True or False accordingly """ # Remove private variables or methods if attr.startswith('_'): return False # Remove any ...
[ "Given", "a", "variable", "and", "one", "of", "its", "attributes", "determine", "if", "the", "attribute", "is", "accessible", "inside", "of", "a", "Django", "template", "and", "return", "True", "or", "False", "accordingly" ]
calebsmith/django-template-debug
python
https://github.com/calebsmith/django-template-debug/blob/f3d52638da571164d63e5c8331d409b0743c628f/template_debug/utils.py#L79-L108
[ "def", "is_valid_in_template", "(", "var", ",", "attr", ")", ":", "# Remove private variables or methods", "if", "attr", ".", "startswith", "(", "'_'", ")", ":", "return", "False", "# Remove any attributes that raise an acception when read", "try", ":", "value", "=", ...
f3d52638da571164d63e5c8331d409b0743c628f
valid
ReleaseCommand.version_bump
Increment version number string 'version'. Type can be one of: major, minor, or bug
seed/commands/release.py
def version_bump(self, version, type="bug"): """ Increment version number string 'version'. Type can be one of: major, minor, or bug """ parsed_version = LooseVersion(version).version total_components = max(3, len(parsed_version)) bits = [] ...
def version_bump(self, version, type="bug"): """ Increment version number string 'version'. Type can be one of: major, minor, or bug """ parsed_version = LooseVersion(version).version total_components = max(3, len(parsed_version)) bits = [] ...
[ "Increment", "version", "number", "string", "version", ".", "Type", "can", "be", "one", "of", ":", "major", "minor", "or", "bug" ]
adamcharnock/seed
python
https://github.com/adamcharnock/seed/blob/48232a2497bd94c5e1466a5b33a929f253ab5112/seed/commands/release.py#L327-L360
[ "def", "version_bump", "(", "self", ",", "version", ",", "type", "=", "\"bug\"", ")", ":", "parsed_version", "=", "LooseVersion", "(", "version", ")", ".", "version", "total_components", "=", "max", "(", "3", ",", "len", "(", "parsed_version", ")", ")", ...
48232a2497bd94c5e1466a5b33a929f253ab5112
valid
GitVcs.parse_log_messages
Will parse git log messages in the 'short' format
seed/vcs/git.py
def parse_log_messages(self, text): """Will parse git log messages in the 'short' format""" regex = r"commit ([0-9a-f]+)\nAuthor: (.*?)\n\n(.*?)(?:\n\n|$)" messages = re.findall(regex, text, re.DOTALL) parsed = [] for commit, author, message in messages: pars...
def parse_log_messages(self, text): """Will parse git log messages in the 'short' format""" regex = r"commit ([0-9a-f]+)\nAuthor: (.*?)\n\n(.*?)(?:\n\n|$)" messages = re.findall(regex, text, re.DOTALL) parsed = [] for commit, author, message in messages: pars...
[ "Will", "parse", "git", "log", "messages", "in", "the", "short", "format" ]
adamcharnock/seed
python
https://github.com/adamcharnock/seed/blob/48232a2497bd94c5e1466a5b33a929f253ab5112/seed/vcs/git.py#L44-L56
[ "def", "parse_log_messages", "(", "self", ",", "text", ")", ":", "regex", "=", "r\"commit ([0-9a-f]+)\\nAuthor: (.*?)\\n\\n(.*?)(?:\\n\\n|$)\"", "messages", "=", "re", ".", "findall", "(", "regex", ",", "text", ",", "re", ".", "DOTALL", ")", "parsed", "=", "[", ...
48232a2497bd94c5e1466a5b33a929f253ab5112
valid
Command.determine_paths
Determine paths automatically and a little intelligently
seed/commands/__init__.py
def determine_paths(self, package_name=None, create_package_dir=False, dry_run=False): """Determine paths automatically and a little intelligently""" # Give preference to the environment variable here as it will not # derefrence sym links self.project_dir = Path(os.getenv('PWD'...
def determine_paths(self, package_name=None, create_package_dir=False, dry_run=False): """Determine paths automatically and a little intelligently""" # Give preference to the environment variable here as it will not # derefrence sym links self.project_dir = Path(os.getenv('PWD'...
[ "Determine", "paths", "automatically", "and", "a", "little", "intelligently" ]
adamcharnock/seed
python
https://github.com/adamcharnock/seed/blob/48232a2497bd94c5e1466a5b33a929f253ab5112/seed/commands/__init__.py#L83-L143
[ "def", "determine_paths", "(", "self", ",", "package_name", "=", "None", ",", "create_package_dir", "=", "False", ",", "dry_run", "=", "False", ")", ":", "# Give preference to the environment variable here as it will not ", "# derefrence sym links", "self", ".", "project_...
48232a2497bd94c5e1466a5b33a929f253ab5112
valid
check_integrity
Checks the format of the sakefile dictionary to ensure it conforms to specification Args: A dictionary that is the parsed Sakefile (from sake.py) The setting dictionary (for print functions) Returns: True if the Sakefile is conformant False if not
sakelib/audit.py
def check_integrity(sakefile, settings): """ Checks the format of the sakefile dictionary to ensure it conforms to specification Args: A dictionary that is the parsed Sakefile (from sake.py) The setting dictionary (for print functions) Returns: True if the Sakefile is confor...
def check_integrity(sakefile, settings): """ Checks the format of the sakefile dictionary to ensure it conforms to specification Args: A dictionary that is the parsed Sakefile (from sake.py) The setting dictionary (for print functions) Returns: True if the Sakefile is confor...
[ "Checks", "the", "format", "of", "the", "sakefile", "dictionary", "to", "ensure", "it", "conforms", "to", "specification" ]
tonyfischetti/sake
python
https://github.com/tonyfischetti/sake/blob/b7ad20fe8e7137db99a20ac06b8da26492601b00/sakelib/audit.py#L49-L98
[ "def", "check_integrity", "(", "sakefile", ",", "settings", ")", ":", "sprint", "=", "settings", "[", "\"sprint\"", "]", "error", "=", "settings", "[", "\"error\"", "]", "sprint", "(", "\"Call to check_integrity issued\"", ",", "level", "=", "\"verbose\"", ")", ...
b7ad20fe8e7137db99a20ac06b8da26492601b00
valid
check_target_integrity
Checks the integrity of a specific target. Gets called multiple times from check_integrity() Args: The target name The dictionary values of that target A boolean representing whether it is a meta-target A boolean representing whether it is the "all" target A string repre...
sakelib/audit.py
def check_target_integrity(key, values, meta=False, all=False, parent=None): """ Checks the integrity of a specific target. Gets called multiple times from check_integrity() Args: The target name The dictionary values of that target A boolean representing whether it is a meta-ta...
def check_target_integrity(key, values, meta=False, all=False, parent=None): """ Checks the integrity of a specific target. Gets called multiple times from check_integrity() Args: The target name The dictionary values of that target A boolean representing whether it is a meta-ta...
[ "Checks", "the", "integrity", "of", "a", "specific", "target", ".", "Gets", "called", "multiple", "times", "from", "check_integrity", "()" ]
tonyfischetti/sake
python
https://github.com/tonyfischetti/sake/blob/b7ad20fe8e7137db99a20ac06b8da26492601b00/sakelib/audit.py#L101-L164
[ "def", "check_target_integrity", "(", "key", ",", "values", ",", "meta", "=", "False", ",", "all", "=", "False", ",", "parent", "=", "None", ")", ":", "# logic to audit \"all\" target", "if", "all", ":", "if", "not", "values", ":", "print", "(", "\"Warning...
b7ad20fe8e7137db99a20ac06b8da26492601b00
valid
check_shastore_version
This function gives us the option to emit errors or warnings after sake upgrades
sakelib/build.py
def check_shastore_version(from_store, settings): """ This function gives us the option to emit errors or warnings after sake upgrades """ sprint = settings["sprint"] error = settings["error"] sprint("checking .shastore version for potential incompatibilities", level="verbose") ...
def check_shastore_version(from_store, settings): """ This function gives us the option to emit errors or warnings after sake upgrades """ sprint = settings["sprint"] error = settings["error"] sprint("checking .shastore version for potential incompatibilities", level="verbose") ...
[ "This", "function", "gives", "us", "the", "option", "to", "emit", "errors", "or", "warnings", "after", "sake", "upgrades" ]
tonyfischetti/sake
python
https://github.com/tonyfischetti/sake/blob/b7ad20fe8e7137db99a20ac06b8da26492601b00/sakelib/build.py#L68-L84
[ "def", "check_shastore_version", "(", "from_store", ",", "settings", ")", ":", "sprint", "=", "settings", "[", "\"sprint\"", "]", "error", "=", "settings", "[", "\"error\"", "]", "sprint", "(", "\"checking .shastore version for potential incompatibilities\"", ",", "le...
b7ad20fe8e7137db99a20ac06b8da26492601b00
valid
get_sha
Returns sha1 hash of the file supplied as an argument
sakelib/build.py
def get_sha(a_file, settings=None): """ Returns sha1 hash of the file supplied as an argument """ if settings: error = settings["error"] else: error = ERROR_FN try: BLOCKSIZE = 65536 hasher = hashlib.sha1() with io.open(a_file, "rb") as fh: buf...
def get_sha(a_file, settings=None): """ Returns sha1 hash of the file supplied as an argument """ if settings: error = settings["error"] else: error = ERROR_FN try: BLOCKSIZE = 65536 hasher = hashlib.sha1() with io.open(a_file, "rb") as fh: buf...
[ "Returns", "sha1", "hash", "of", "the", "file", "supplied", "as", "an", "argument" ]
tonyfischetti/sake
python
https://github.com/tonyfischetti/sake/blob/b7ad20fe8e7137db99a20ac06b8da26492601b00/sakelib/build.py#L87-L112
[ "def", "get_sha", "(", "a_file", ",", "settings", "=", "None", ")", ":", "if", "settings", ":", "error", "=", "settings", "[", "\"error\"", "]", "else", ":", "error", "=", "ERROR_FN", "try", ":", "BLOCKSIZE", "=", "65536", "hasher", "=", "hashlib", "."...
b7ad20fe8e7137db99a20ac06b8da26492601b00
valid
write_shas_to_shastore
Writes a sha1 dictionary stored in memory to the .shastore file
sakelib/build.py
def write_shas_to_shastore(sha_dict): """ Writes a sha1 dictionary stored in memory to the .shastore file """ if sys.version_info[0] < 3: fn_open = open else: fn_open = io.open with fn_open(".shastore", "w") as fh: fh.write("---\n") fh.write('sake version: {}\...
def write_shas_to_shastore(sha_dict): """ Writes a sha1 dictionary stored in memory to the .shastore file """ if sys.version_info[0] < 3: fn_open = open else: fn_open = io.open with fn_open(".shastore", "w") as fh: fh.write("---\n") fh.write('sake version: {}\...
[ "Writes", "a", "sha1", "dictionary", "stored", "in", "memory", "to", "the", ".", "shastore", "file" ]
tonyfischetti/sake
python
https://github.com/tonyfischetti/sake/blob/b7ad20fe8e7137db99a20ac06b8da26492601b00/sakelib/build.py#L115-L129
[ "def", "write_shas_to_shastore", "(", "sha_dict", ")", ":", "if", "sys", ".", "version_info", "[", "0", "]", "<", "3", ":", "fn_open", "=", "open", "else", ":", "fn_open", "=", "io", ".", "open", "with", "fn_open", "(", "\".shastore\"", ",", "\"w\"", "...
b7ad20fe8e7137db99a20ac06b8da26492601b00
valid
take_shas_of_all_files
Takes sha1 hash of all dependencies and outputs of all targets Args: The graph we are going to build The settings dictionary Returns: A dictionary where the keys are the filenames and the value is the sha1 hash
sakelib/build.py
def take_shas_of_all_files(G, settings): """ Takes sha1 hash of all dependencies and outputs of all targets Args: The graph we are going to build The settings dictionary Returns: A dictionary where the keys are the filenames and the value is the sha1 hash """ gl...
def take_shas_of_all_files(G, settings): """ Takes sha1 hash of all dependencies and outputs of all targets Args: The graph we are going to build The settings dictionary Returns: A dictionary where the keys are the filenames and the value is the sha1 hash """ gl...
[ "Takes", "sha1", "hash", "of", "all", "dependencies", "and", "outputs", "of", "all", "targets" ]
tonyfischetti/sake
python
https://github.com/tonyfischetti/sake/blob/b7ad20fe8e7137db99a20ac06b8da26492601b00/sakelib/build.py#L132-L186
[ "def", "take_shas_of_all_files", "(", "G", ",", "settings", ")", ":", "global", "ERROR_FN", "sprint", "=", "settings", "[", "\"sprint\"", "]", "error", "=", "settings", "[", "\"error\"", "]", "ERROR_FN", "=", "error", "sha_dict", "=", "{", "}", "all_files", ...
b7ad20fe8e7137db99a20ac06b8da26492601b00
valid
needs_to_run
Determines if a target needs to run. This can happen in two ways: (a) If a dependency of the target has changed (b) If an output of the target is missing Args: The graph we are going to build The name of the target The dictionary of the current shas held in memory The dictio...
sakelib/build.py
def needs_to_run(G, target, in_mem_shas, from_store, settings): """ Determines if a target needs to run. This can happen in two ways: (a) If a dependency of the target has changed (b) If an output of the target is missing Args: The graph we are going to build The name of the target ...
def needs_to_run(G, target, in_mem_shas, from_store, settings): """ Determines if a target needs to run. This can happen in two ways: (a) If a dependency of the target has changed (b) If an output of the target is missing Args: The graph we are going to build The name of the target ...
[ "Determines", "if", "a", "target", "needs", "to", "run", ".", "This", "can", "happen", "in", "two", "ways", ":", "(", "a", ")", "If", "a", "dependency", "of", "the", "target", "has", "changed", "(", "b", ")", "If", "an", "output", "of", "the", "tar...
tonyfischetti/sake
python
https://github.com/tonyfischetti/sake/blob/b7ad20fe8e7137db99a20ac06b8da26492601b00/sakelib/build.py#L189-L247
[ "def", "needs_to_run", "(", "G", ",", "target", ",", "in_mem_shas", ",", "from_store", ",", "settings", ")", ":", "force", "=", "settings", "[", "\"force\"", "]", "sprint", "=", "settings", "[", "\"sprint\"", "]", "if", "(", "force", ")", ":", "sprint", ...
b7ad20fe8e7137db99a20ac06b8da26492601b00
valid
run_commands
Runs the commands supplied as an argument It will exit the program if the commands return a non-zero code Args: the commands to run The settings dictionary
sakelib/build.py
def run_commands(commands, settings): """ Runs the commands supplied as an argument It will exit the program if the commands return a non-zero code Args: the commands to run The settings dictionary """ sprint = settings["sprint"] quiet = settings["quiet"] error = set...
def run_commands(commands, settings): """ Runs the commands supplied as an argument It will exit the program if the commands return a non-zero code Args: the commands to run The settings dictionary """ sprint = settings["sprint"] quiet = settings["quiet"] error = set...
[ "Runs", "the", "commands", "supplied", "as", "an", "argument", "It", "will", "exit", "the", "program", "if", "the", "commands", "return", "a", "non", "-", "zero", "code" ]
tonyfischetti/sake
python
https://github.com/tonyfischetti/sake/blob/b7ad20fe8e7137db99a20ac06b8da26492601b00/sakelib/build.py#L250-L301
[ "def", "run_commands", "(", "commands", ",", "settings", ")", ":", "sprint", "=", "settings", "[", "\"sprint\"", "]", "quiet", "=", "settings", "[", "\"quiet\"", "]", "error", "=", "settings", "[", "\"error\"", "]", "enhanced_errors", "=", "True", "the_shell...
b7ad20fe8e7137db99a20ac06b8da26492601b00
valid
run_the_target
Wrapper function that sends to commands in a target's 'formula' to run_commands() Args: The graph we are going to build The target to run The settings dictionary
sakelib/build.py
def run_the_target(G, target, settings): """ Wrapper function that sends to commands in a target's 'formula' to run_commands() Args: The graph we are going to build The target to run The settings dictionary """ sprint = settings["sprint"] sprint("Running target {}".f...
def run_the_target(G, target, settings): """ Wrapper function that sends to commands in a target's 'formula' to run_commands() Args: The graph we are going to build The target to run The settings dictionary """ sprint = settings["sprint"] sprint("Running target {}".f...
[ "Wrapper", "function", "that", "sends", "to", "commands", "in", "a", "target", "s", "formula", "to", "run_commands", "()" ]
tonyfischetti/sake
python
https://github.com/tonyfischetti/sake/blob/b7ad20fe8e7137db99a20ac06b8da26492601b00/sakelib/build.py#L304-L317
[ "def", "run_the_target", "(", "G", ",", "target", ",", "settings", ")", ":", "sprint", "=", "settings", "[", "\"sprint\"", "]", "sprint", "(", "\"Running target {}\"", ".", "format", "(", "target", ")", ")", "the_formula", "=", "get_the_node_dict", "(", "G",...
b7ad20fe8e7137db99a20ac06b8da26492601b00
valid
get_the_node_dict
Helper function that returns the node data of the node with the name supplied
sakelib/build.py
def get_the_node_dict(G, name): """ Helper function that returns the node data of the node with the name supplied """ for node in G.nodes(data=True): if node[0] == name: return node[1]
def get_the_node_dict(G, name): """ Helper function that returns the node data of the node with the name supplied """ for node in G.nodes(data=True): if node[0] == name: return node[1]
[ "Helper", "function", "that", "returns", "the", "node", "data", "of", "the", "node", "with", "the", "name", "supplied" ]
tonyfischetti/sake
python
https://github.com/tonyfischetti/sake/blob/b7ad20fe8e7137db99a20ac06b8da26492601b00/sakelib/build.py#L320-L327
[ "def", "get_the_node_dict", "(", "G", ",", "name", ")", ":", "for", "node", "in", "G", ".", "nodes", "(", "data", "=", "True", ")", ":", "if", "node", "[", "0", "]", "==", "name", ":", "return", "node", "[", "1", "]" ]
b7ad20fe8e7137db99a20ac06b8da26492601b00
valid
get_direct_ancestors
Returns a list of nodes that are the parents from all of the nodes given as an argument. This is for use in the parallel topo sort
sakelib/build.py
def get_direct_ancestors(G, list_of_nodes): """ Returns a list of nodes that are the parents from all of the nodes given as an argument. This is for use in the parallel topo sort """ parents = [] for item in list_of_nodes: anc = G.predecessors(item) for one in anc: ...
def get_direct_ancestors(G, list_of_nodes): """ Returns a list of nodes that are the parents from all of the nodes given as an argument. This is for use in the parallel topo sort """ parents = [] for item in list_of_nodes: anc = G.predecessors(item) for one in anc: ...
[ "Returns", "a", "list", "of", "nodes", "that", "are", "the", "parents", "from", "all", "of", "the", "nodes", "given", "as", "an", "argument", ".", "This", "is", "for", "use", "in", "the", "parallel", "topo", "sort" ]
tonyfischetti/sake
python
https://github.com/tonyfischetti/sake/blob/b7ad20fe8e7137db99a20ac06b8da26492601b00/sakelib/build.py#L330-L341
[ "def", "get_direct_ancestors", "(", "G", ",", "list_of_nodes", ")", ":", "parents", "=", "[", "]", "for", "item", "in", "list_of_nodes", ":", "anc", "=", "G", ".", "predecessors", "(", "item", ")", "for", "one", "in", "anc", ":", "parents", ".", "appen...
b7ad20fe8e7137db99a20ac06b8da26492601b00
valid
get_sinks
A sink is a node with no children. This means that this is the end of the line, and it should be run last in topo sort. This returns a list of all sinks in a graph
sakelib/build.py
def get_sinks(G): """ A sink is a node with no children. This means that this is the end of the line, and it should be run last in topo sort. This returns a list of all sinks in a graph """ sinks = [] for node in G: if not len(list(G.successors(node))): sinks.append(n...
def get_sinks(G): """ A sink is a node with no children. This means that this is the end of the line, and it should be run last in topo sort. This returns a list of all sinks in a graph """ sinks = [] for node in G: if not len(list(G.successors(node))): sinks.append(n...
[ "A", "sink", "is", "a", "node", "with", "no", "children", ".", "This", "means", "that", "this", "is", "the", "end", "of", "the", "line", "and", "it", "should", "be", "run", "last", "in", "topo", "sort", ".", "This", "returns", "a", "list", "of", "a...
tonyfischetti/sake
python
https://github.com/tonyfischetti/sake/blob/b7ad20fe8e7137db99a20ac06b8da26492601b00/sakelib/build.py#L344-L355
[ "def", "get_sinks", "(", "G", ")", ":", "sinks", "=", "[", "]", "for", "node", "in", "G", ":", "if", "not", "len", "(", "list", "(", "G", ".", "successors", "(", "node", ")", ")", ")", ":", "sinks", ".", "append", "(", "node", ")", "return", ...
b7ad20fe8e7137db99a20ac06b8da26492601b00
valid
get_levels
For the parallel topo sort to work, the targets have to be executed in layers such that there is no dependency relationship between any nodes in a layer. What is returned is a list of lists representing all the layers, or levels
sakelib/build.py
def get_levels(G): """ For the parallel topo sort to work, the targets have to be executed in layers such that there is no dependency relationship between any nodes in a layer. What is returned is a list of lists representing all the layers, or levels """ levels = [] ends = get_sinks...
def get_levels(G): """ For the parallel topo sort to work, the targets have to be executed in layers such that there is no dependency relationship between any nodes in a layer. What is returned is a list of lists representing all the layers, or levels """ levels = [] ends = get_sinks...
[ "For", "the", "parallel", "topo", "sort", "to", "work", "the", "targets", "have", "to", "be", "executed", "in", "layers", "such", "that", "there", "is", "no", "dependency", "relationship", "between", "any", "nodes", "in", "a", "layer", ".", "What", "is", ...
tonyfischetti/sake
python
https://github.com/tonyfischetti/sake/blob/b7ad20fe8e7137db99a20ac06b8da26492601b00/sakelib/build.py#L358-L373
[ "def", "get_levels", "(", "G", ")", ":", "levels", "=", "[", "]", "ends", "=", "get_sinks", "(", "G", ")", "levels", ".", "append", "(", "ends", ")", "while", "get_direct_ancestors", "(", "G", ",", "ends", ")", ":", "ends", "=", "get_direct_ancestors",...
b7ad20fe8e7137db99a20ac06b8da26492601b00
valid
remove_redundancies
There are repeats in the output from get_levels(). We want only the earliest occurrence (after it's reversed)
sakelib/build.py
def remove_redundancies(levels): """ There are repeats in the output from get_levels(). We want only the earliest occurrence (after it's reversed) """ seen = [] final = [] for line in levels: new_line = [] for item in line: if item not in seen: see...
def remove_redundancies(levels): """ There are repeats in the output from get_levels(). We want only the earliest occurrence (after it's reversed) """ seen = [] final = [] for line in levels: new_line = [] for item in line: if item not in seen: see...
[ "There", "are", "repeats", "in", "the", "output", "from", "get_levels", "()", ".", "We", "want", "only", "the", "earliest", "occurrence", "(", "after", "it", "s", "reversed", ")" ]
tonyfischetti/sake
python
https://github.com/tonyfischetti/sake/blob/b7ad20fe8e7137db99a20ac06b8da26492601b00/sakelib/build.py#L376-L390
[ "def", "remove_redundancies", "(", "levels", ")", ":", "seen", "=", "[", "]", "final", "=", "[", "]", "for", "line", "in", "levels", ":", "new_line", "=", "[", "]", "for", "item", "in", "line", ":", "if", "item", "not", "in", "seen", ":", "seen", ...
b7ad20fe8e7137db99a20ac06b8da26492601b00
valid
parallel_run_these
The parallel equivalent of "run_this_target()" It receives a list of targets to execute in parallel. Unlike "run_this_target()" it has to update the shas (in memory and in the store) within the function. This is because one of the targets may fail but many can succeed, and those outputs need to be u...
sakelib/build.py
def parallel_run_these(G, list_of_targets, in_mem_shas, from_store, settings, dont_update_shas_of): """ The parallel equivalent of "run_this_target()" It receives a list of targets to execute in parallel. Unlike "run_this_target()" it has to update the shas (in memory and in t...
def parallel_run_these(G, list_of_targets, in_mem_shas, from_store, settings, dont_update_shas_of): """ The parallel equivalent of "run_this_target()" It receives a list of targets to execute in parallel. Unlike "run_this_target()" it has to update the shas (in memory and in t...
[ "The", "parallel", "equivalent", "of", "run_this_target", "()", "It", "receives", "a", "list", "of", "targets", "to", "execute", "in", "parallel", ".", "Unlike", "run_this_target", "()", "it", "has", "to", "update", "the", "shas", "(", "in", "memory", "and",...
tonyfischetti/sake
python
https://github.com/tonyfischetti/sake/blob/b7ad20fe8e7137db99a20ac06b8da26492601b00/sakelib/build.py#L404-L477
[ "def", "parallel_run_these", "(", "G", ",", "list_of_targets", ",", "in_mem_shas", ",", "from_store", ",", "settings", ",", "dont_update_shas_of", ")", ":", "verbose", "=", "settings", "[", "\"verbose\"", "]", "quiet", "=", "settings", "[", "\"quiet\"", "]", "...
b7ad20fe8e7137db99a20ac06b8da26492601b00
valid
merge_from_store_and_in_mems
If we don't merge the shas from the sha store and if we build a subgraph, the .shastore will only contain the shas of the files from the subgraph and the rest of the graph will have to be rebuilt
sakelib/build.py
def merge_from_store_and_in_mems(from_store, in_mem_shas, dont_update_shas_of): """ If we don't merge the shas from the sha store and if we build a subgraph, the .shastore will only contain the shas of the files from the subgraph and the rest of the graph will have to be rebuilt """ if not f...
def merge_from_store_and_in_mems(from_store, in_mem_shas, dont_update_shas_of): """ If we don't merge the shas from the sha store and if we build a subgraph, the .shastore will only contain the shas of the files from the subgraph and the rest of the graph will have to be rebuilt """ if not f...
[ "If", "we", "don", "t", "merge", "the", "shas", "from", "the", "sha", "store", "and", "if", "we", "build", "a", "subgraph", "the", ".", "shastore", "will", "only", "contain", "the", "shas", "of", "the", "files", "from", "the", "subgraph", "and", "the",...
tonyfischetti/sake
python
https://github.com/tonyfischetti/sake/blob/b7ad20fe8e7137db99a20ac06b8da26492601b00/sakelib/build.py#L480-L498
[ "def", "merge_from_store_and_in_mems", "(", "from_store", ",", "in_mem_shas", ",", "dont_update_shas_of", ")", ":", "if", "not", "from_store", ":", "for", "item", "in", "dont_update_shas_of", ":", "if", "item", "in", "in_mem_shas", "[", "'files'", "]", ":", "del...
b7ad20fe8e7137db99a20ac06b8da26492601b00
valid
build_this_graph
This is the master function that performs the building. Args: A graph (often a subgraph) The settings dictionary An optional list of files to not update the shas of (needed when building specific targets) Returns: 0 if successful UN-success results in a fatal ...
sakelib/build.py
def build_this_graph(G, settings, dont_update_shas_of=None): """ This is the master function that performs the building. Args: A graph (often a subgraph) The settings dictionary An optional list of files to not update the shas of (needed when building specific targets) ...
def build_this_graph(G, settings, dont_update_shas_of=None): """ This is the master function that performs the building. Args: A graph (often a subgraph) The settings dictionary An optional list of files to not update the shas of (needed when building specific targets) ...
[ "This", "is", "the", "master", "function", "that", "performs", "the", "building", "." ]
tonyfischetti/sake
python
https://github.com/tonyfischetti/sake/blob/b7ad20fe8e7137db99a20ac06b8da26492601b00/sakelib/build.py#L501-L609
[ "def", "build_this_graph", "(", "G", ",", "settings", ",", "dont_update_shas_of", "=", "None", ")", ":", "verbose", "=", "settings", "[", "\"verbose\"", "]", "quiet", "=", "settings", "[", "\"quiet\"", "]", "force", "=", "settings", "[", "\"force\"", "]", ...
b7ad20fe8e7137db99a20ac06b8da26492601b00
valid
get_print_functions
This returns the appropriate print functions in a tuple The print function are: - sprint - for standard printing - warn - for warnings - error - for errors This will all be the same if color is False. The returned print functions will contain an optional parameter that speci...
sakelib/acts.py
def get_print_functions(settings): """ This returns the appropriate print functions in a tuple The print function are: - sprint - for standard printing - warn - for warnings - error - for errors This will all be the same if color is False. The returned print functions wi...
def get_print_functions(settings): """ This returns the appropriate print functions in a tuple The print function are: - sprint - for standard printing - warn - for warnings - error - for errors This will all be the same if color is False. The returned print functions wi...
[ "This", "returns", "the", "appropriate", "print", "functions", "in", "a", "tuple", "The", "print", "function", "are", ":", "-", "sprint", "-", "for", "standard", "printing", "-", "warn", "-", "for", "warnings", "-", "error", "-", "for", "errors", "This", ...
tonyfischetti/sake
python
https://github.com/tonyfischetti/sake/blob/b7ad20fe8e7137db99a20ac06b8da26492601b00/sakelib/acts.py#L64-L115
[ "def", "get_print_functions", "(", "settings", ")", ":", "verbose", "=", "settings", "[", "\"verbose\"", "]", "# the regular print doesn't use color by default", "# (even if color is True)", "def", "sprint", "(", "message", ",", "level", "=", "None", ",", "color", "="...
b7ad20fe8e7137db99a20ac06b8da26492601b00
valid
find_standard_sakefile
Returns the filename of the appropriate sakefile
sakelib/acts.py
def find_standard_sakefile(settings): """Returns the filename of the appropriate sakefile""" error = settings["error"] if settings["customsake"]: custom = settings["customsake"] if not os.path.isfile(custom): error("Specified sakefile '{}' doesn't exist", custom) sys....
def find_standard_sakefile(settings): """Returns the filename of the appropriate sakefile""" error = settings["error"] if settings["customsake"]: custom = settings["customsake"] if not os.path.isfile(custom): error("Specified sakefile '{}' doesn't exist", custom) sys....
[ "Returns", "the", "filename", "of", "the", "appropriate", "sakefile" ]
tonyfischetti/sake
python
https://github.com/tonyfischetti/sake/blob/b7ad20fe8e7137db99a20ac06b8da26492601b00/sakelib/acts.py#L118-L132
[ "def", "find_standard_sakefile", "(", "settings", ")", ":", "error", "=", "settings", "[", "\"error\"", "]", "if", "settings", "[", "\"customsake\"", "]", ":", "custom", "=", "settings", "[", "\"customsake\"", "]", "if", "not", "os", ".", "path", ".", "isf...
b7ad20fe8e7137db99a20ac06b8da26492601b00
valid
clean_path
This function is used to normalize the path (of an output or dependency) and also provide the path in relative form. It is relative to the current working directory
sakelib/acts.py
def clean_path(a_path, force_os=None, force_start=None): """ This function is used to normalize the path (of an output or dependency) and also provide the path in relative form. It is relative to the current working directory """ if not force_start: force_start = os.curdir if force_o...
def clean_path(a_path, force_os=None, force_start=None): """ This function is used to normalize the path (of an output or dependency) and also provide the path in relative form. It is relative to the current working directory """ if not force_start: force_start = os.curdir if force_o...
[ "This", "function", "is", "used", "to", "normalize", "the", "path", "(", "of", "an", "output", "or", "dependency", ")", "and", "also", "provide", "the", "path", "in", "relative", "form", ".", "It", "is", "relative", "to", "the", "current", "working", "di...
tonyfischetti/sake
python
https://github.com/tonyfischetti/sake/blob/b7ad20fe8e7137db99a20ac06b8da26492601b00/sakelib/acts.py#L149-L166
[ "def", "clean_path", "(", "a_path", ",", "force_os", "=", "None", ",", "force_start", "=", "None", ")", ":", "if", "not", "force_start", ":", "force_start", "=", "os", ".", "curdir", "if", "force_os", "==", "\"windows\"", ":", "import", "ntpath", "return",...
b7ad20fe8e7137db99a20ac06b8da26492601b00
valid
get_help
Returns the prettily formatted help strings (for printing) Args: A dictionary that is the parsed Sakefile (from sake.py) NOTE: the list sorting in this function is required for this function to be deterministic
sakelib/acts.py
def get_help(sakefile): """ Returns the prettily formatted help strings (for printing) Args: A dictionary that is the parsed Sakefile (from sake.py) NOTE: the list sorting in this function is required for this function to be deterministic """ full_string = "You can 'sak...
def get_help(sakefile): """ Returns the prettily formatted help strings (for printing) Args: A dictionary that is the parsed Sakefile (from sake.py) NOTE: the list sorting in this function is required for this function to be deterministic """ full_string = "You can 'sak...
[ "Returns", "the", "prettily", "formatted", "help", "strings", "(", "for", "printing", ")" ]
tonyfischetti/sake
python
https://github.com/tonyfischetti/sake/blob/b7ad20fe8e7137db99a20ac06b8da26492601b00/sakelib/acts.py#L181-L226
[ "def", "get_help", "(", "sakefile", ")", ":", "full_string", "=", "\"You can 'sake' one of the following...\\n\\n\"", "errmes", "=", "\"target '{}' is not allowed to not have help message\\n\"", "outerlines", "=", "[", "]", "for", "target", "in", "sakefile", ":", "if", "t...
b7ad20fe8e7137db99a20ac06b8da26492601b00
valid
parse_defines
This parses a list of define argument in the form of -DNAME=VALUE or -DNAME ( which is treated as -DNAME=1).
sakelib/acts.py
def parse_defines(args): """ This parses a list of define argument in the form of -DNAME=VALUE or -DNAME ( which is treated as -DNAME=1). """ macros = {} for arg in args: try: var, val = arg.split('=', 1) except ValueError: var = arg val = '1' ...
def parse_defines(args): """ This parses a list of define argument in the form of -DNAME=VALUE or -DNAME ( which is treated as -DNAME=1). """ macros = {} for arg in args: try: var, val = arg.split('=', 1) except ValueError: var = arg val = '1' ...
[ "This", "parses", "a", "list", "of", "define", "argument", "in", "the", "form", "of", "-", "DNAME", "=", "VALUE", "or", "-", "DNAME", "(", "which", "is", "treated", "as", "-", "DNAME", "=", "1", ")", "." ]
tonyfischetti/sake
python
https://github.com/tonyfischetti/sake/blob/b7ad20fe8e7137db99a20ac06b8da26492601b00/sakelib/acts.py#L229-L244
[ "def", "parse_defines", "(", "args", ")", ":", "macros", "=", "{", "}", "for", "arg", "in", "args", ":", "try", ":", "var", ",", "val", "=", "arg", ".", "split", "(", "'='", ",", "1", ")", "except", "ValueError", ":", "var", "=", "arg", "val", ...
b7ad20fe8e7137db99a20ac06b8da26492601b00
valid
expand_macros
this gets called before the sakefile is parsed. it looks for macros defined anywhere in the sakefile (the start of the line is '#!') and then replaces all occurences of '$variable' with the value defined in the macro. it then returns the contents of the file with the macros expanded.
sakelib/acts.py
def expand_macros(raw_text, macros): """ this gets called before the sakefile is parsed. it looks for macros defined anywhere in the sakefile (the start of the line is '#!') and then replaces all occurences of '$variable' with the value defined in the macro. it then returns the contents of the f...
def expand_macros(raw_text, macros): """ this gets called before the sakefile is parsed. it looks for macros defined anywhere in the sakefile (the start of the line is '#!') and then replaces all occurences of '$variable' with the value defined in the macro. it then returns the contents of the f...
[ "this", "gets", "called", "before", "the", "sakefile", "is", "parsed", ".", "it", "looks", "for", "macros", "defined", "anywhere", "in", "the", "sakefile", "(", "the", "start", "of", "the", "line", "is", "#!", ")", "and", "then", "replaces", "all", "occu...
tonyfischetti/sake
python
https://github.com/tonyfischetti/sake/blob/b7ad20fe8e7137db99a20ac06b8da26492601b00/sakelib/acts.py#L247-L294
[ "def", "expand_macros", "(", "raw_text", ",", "macros", ")", ":", "includes", "=", "{", "}", "result", "=", "[", "]", "pattern", "=", "re", ".", "compile", "(", "\"#!\\s*(\\w+)\\s*(?:(\\??\\s*)=\\s*(.*$)|or\\s*(.*))\"", ",", "re", ".", "UNICODE", ")", "ipatter...
b7ad20fe8e7137db99a20ac06b8da26492601b00
valid
check_for_dep_in_outputs
Function to help construct_graph() identify dependencies Args: A dependency A flag indication verbosity A (populated) NetworkX DiGraph Returns: A list of targets that build given dependency
sakelib/acts.py
def check_for_dep_in_outputs(dep, verbose, G): """ Function to help construct_graph() identify dependencies Args: A dependency A flag indication verbosity A (populated) NetworkX DiGraph Returns: A list of targets that build given dependency """ if verbose: ...
def check_for_dep_in_outputs(dep, verbose, G): """ Function to help construct_graph() identify dependencies Args: A dependency A flag indication verbosity A (populated) NetworkX DiGraph Returns: A list of targets that build given dependency """ if verbose: ...
[ "Function", "to", "help", "construct_graph", "()", "identify", "dependencies" ]
tonyfischetti/sake
python
https://github.com/tonyfischetti/sake/blob/b7ad20fe8e7137db99a20ac06b8da26492601b00/sakelib/acts.py#L297-L320
[ "def", "check_for_dep_in_outputs", "(", "dep", ",", "verbose", ",", "G", ")", ":", "if", "verbose", ":", "print", "(", "\"checking dep {}\"", ".", "format", "(", "dep", ")", ")", "ret_list", "=", "[", "]", "for", "node", "in", "G", ".", "nodes", "(", ...
b7ad20fe8e7137db99a20ac06b8da26492601b00
valid
get_ties
If you specify a target that shares a dependency with another target, both targets need to be updated. This is because running one will resolve the sha mismatch and sake will think that the other one doesn't have to run. This is called a "tie". This function will find such ties.
sakelib/acts.py
def get_ties(G): """ If you specify a target that shares a dependency with another target, both targets need to be updated. This is because running one will resolve the sha mismatch and sake will think that the other one doesn't have to run. This is called a "tie". This function will find such ties....
def get_ties(G): """ If you specify a target that shares a dependency with another target, both targets need to be updated. This is because running one will resolve the sha mismatch and sake will think that the other one doesn't have to run. This is called a "tie". This function will find such ties....
[ "If", "you", "specify", "a", "target", "that", "shares", "a", "dependency", "with", "another", "target", "both", "targets", "need", "to", "be", "updated", ".", "This", "is", "because", "running", "one", "will", "resolve", "the", "sha", "mismatch", "and", "...
tonyfischetti/sake
python
https://github.com/tonyfischetti/sake/blob/b7ad20fe8e7137db99a20ac06b8da26492601b00/sakelib/acts.py#L409-L431
[ "def", "get_ties", "(", "G", ")", ":", "# we are going to make a dictionary whose keys are every dependency", "# and whose values are a list of all targets that use that dependency.", "# after making the dictionary, values whose length is above one will", "# be called \"ties\"", "ties", "=", ...
b7ad20fe8e7137db99a20ac06b8da26492601b00
valid
get_tied_targets
This function gets called when a target is specified to ensure that all 'tied' targets also get included in the subgraph to be built
sakelib/acts.py
def get_tied_targets(original_targets, the_ties): """ This function gets called when a target is specified to ensure that all 'tied' targets also get included in the subgraph to be built """ my_ties = [] for original_target in original_targets: for item in the_ties: if or...
def get_tied_targets(original_targets, the_ties): """ This function gets called when a target is specified to ensure that all 'tied' targets also get included in the subgraph to be built """ my_ties = [] for original_target in original_targets: for item in the_ties: if or...
[ "This", "function", "gets", "called", "when", "a", "target", "is", "specified", "to", "ensure", "that", "all", "tied", "targets", "also", "get", "included", "in", "the", "subgraph", "to", "be", "built" ]
tonyfischetti/sake
python
https://github.com/tonyfischetti/sake/blob/b7ad20fe8e7137db99a20ac06b8da26492601b00/sakelib/acts.py#L434-L453
[ "def", "get_tied_targets", "(", "original_targets", ",", "the_ties", ")", ":", "my_ties", "=", "[", "]", "for", "original_target", "in", "original_targets", ":", "for", "item", "in", "the_ties", ":", "if", "original_target", "in", "item", ":", "for", "thing", ...
b7ad20fe8e7137db99a20ac06b8da26492601b00
valid
construct_graph
Takes the sakefile dictionary and builds a NetworkX graph Args: A dictionary that is the parsed Sakefile (from sake.py) The settings dictionary Returns: A NetworkX graph
sakelib/acts.py
def construct_graph(sakefile, settings): """ Takes the sakefile dictionary and builds a NetworkX graph Args: A dictionary that is the parsed Sakefile (from sake.py) The settings dictionary Returns: A NetworkX graph """ verbose = settings["verbose"] sprint = settings...
def construct_graph(sakefile, settings): """ Takes the sakefile dictionary and builds a NetworkX graph Args: A dictionary that is the parsed Sakefile (from sake.py) The settings dictionary Returns: A NetworkX graph """ verbose = settings["verbose"] sprint = settings...
[ "Takes", "the", "sakefile", "dictionary", "and", "builds", "a", "NetworkX", "graph" ]
tonyfischetti/sake
python
https://github.com/tonyfischetti/sake/blob/b7ad20fe8e7137db99a20ac06b8da26492601b00/sakelib/acts.py#L456-L520
[ "def", "construct_graph", "(", "sakefile", ",", "settings", ")", ":", "verbose", "=", "settings", "[", "\"verbose\"", "]", "sprint", "=", "settings", "[", "\"sprint\"", "]", "G", "=", "nx", ".", "DiGraph", "(", ")", "sprint", "(", "\"Going to construct Graph...
b7ad20fe8e7137db99a20ac06b8da26492601b00
valid
get_all_outputs
This function takes a node dictionary and returns a list of the node's output files. Some of the entries in the 'output' attribute may be globs, and without this function, sake won't know how to handle that. This will unglob all globs and return the true list of *all* outputs.
sakelib/acts.py
def get_all_outputs(node_dict): """ This function takes a node dictionary and returns a list of the node's output files. Some of the entries in the 'output' attribute may be globs, and without this function, sake won't know how to handle that. This will unglob all globs and return the true list ...
def get_all_outputs(node_dict): """ This function takes a node dictionary and returns a list of the node's output files. Some of the entries in the 'output' attribute may be globs, and without this function, sake won't know how to handle that. This will unglob all globs and return the true list ...
[ "This", "function", "takes", "a", "node", "dictionary", "and", "returns", "a", "list", "of", "the", "node", "s", "output", "files", ".", "Some", "of", "the", "entries", "in", "the", "output", "attribute", "may", "be", "globs", "and", "without", "this", "...
tonyfischetti/sake
python
https://github.com/tonyfischetti/sake/blob/b7ad20fe8e7137db99a20ac06b8da26492601b00/sakelib/acts.py#L523-L539
[ "def", "get_all_outputs", "(", "node_dict", ")", ":", "outlist", "=", "[", "]", "for", "item", "in", "node_dict", "[", "'output'", "]", ":", "glist", "=", "glob", ".", "glob", "(", "item", ")", "if", "glist", ":", "for", "oneglob", "in", "glist", ":"...
b7ad20fe8e7137db99a20ac06b8da26492601b00
valid
get_all_dependencies
...............................
sakelib/acts.py
def get_all_dependencies(node_dict): """ ............................... """ deplist = [] for item in node_dict['dependencies']: glist = glob.glob(item) if glist: for oneglob in glist: deplist.append(oneglob) else: deplist.append(item) ...
def get_all_dependencies(node_dict): """ ............................... """ deplist = [] for item in node_dict['dependencies']: glist = glob.glob(item) if glist: for oneglob in glist: deplist.append(oneglob) else: deplist.append(item) ...
[ "..............................." ]
tonyfischetti/sake
python
https://github.com/tonyfischetti/sake/blob/b7ad20fe8e7137db99a20ac06b8da26492601b00/sakelib/acts.py#L542-L554
[ "def", "get_all_dependencies", "(", "node_dict", ")", ":", "deplist", "=", "[", "]", "for", "item", "in", "node_dict", "[", "'dependencies'", "]", ":", "glist", "=", "glob", ".", "glob", "(", "item", ")", "if", "glist", ":", "for", "oneglob", "in", "gl...
b7ad20fe8e7137db99a20ac06b8da26492601b00
valid
clean_all
Removes all the output files from all targets. Takes the graph as the only argument Args: The networkx graph object The settings dictionary Returns: 0 if successful 1 if removing even one file failed
sakelib/acts.py
def clean_all(G, settings): """ Removes all the output files from all targets. Takes the graph as the only argument Args: The networkx graph object The settings dictionary Returns: 0 if successful 1 if removing even one file failed """ quiet = settings["quie...
def clean_all(G, settings): """ Removes all the output files from all targets. Takes the graph as the only argument Args: The networkx graph object The settings dictionary Returns: 0 if successful 1 if removing even one file failed """ quiet = settings["quie...
[ "Removes", "all", "the", "output", "files", "from", "all", "targets", ".", "Takes", "the", "graph", "as", "the", "only", "argument" ]
tonyfischetti/sake
python
https://github.com/tonyfischetti/sake/blob/b7ad20fe8e7137db99a20ac06b8da26492601b00/sakelib/acts.py#L557-L596
[ "def", "clean_all", "(", "G", ",", "settings", ")", ":", "quiet", "=", "settings", "[", "\"quiet\"", "]", "recon", "=", "settings", "[", "\"recon\"", "]", "sprint", "=", "settings", "[", "\"sprint\"", "]", "error", "=", "settings", "[", "\"error\"", "]",...
b7ad20fe8e7137db99a20ac06b8da26492601b00
valid
write_dot_file
Writes the graph G in dot file format for graphviz visualization. Args: a Networkx graph A filename to name the dot files
sakelib/acts.py
def write_dot_file(G, filename): """ Writes the graph G in dot file format for graphviz visualization. Args: a Networkx graph A filename to name the dot files """ with io.open(filename, "w") as fh: fh.write("strict digraph DependencyDiagram {\n") edge_list = G.edges(...
def write_dot_file(G, filename): """ Writes the graph G in dot file format for graphviz visualization. Args: a Networkx graph A filename to name the dot files """ with io.open(filename, "w") as fh: fh.write("strict digraph DependencyDiagram {\n") edge_list = G.edges(...
[ "Writes", "the", "graph", "G", "in", "dot", "file", "format", "for", "graphviz", "visualization", "." ]
tonyfischetti/sake
python
https://github.com/tonyfischetti/sake/blob/b7ad20fe8e7137db99a20ac06b8da26492601b00/sakelib/acts.py#L599-L623
[ "def", "write_dot_file", "(", "G", ",", "filename", ")", ":", "with", "io", ".", "open", "(", "filename", ",", "\"w\"", ")", "as", "fh", ":", "fh", ".", "write", "(", "\"strict digraph DependencyDiagram {\\n\"", ")", "edge_list", "=", "G", ".", "edges", ...
b7ad20fe8e7137db99a20ac06b8da26492601b00
valid
visualize
Uses networkX to draw a graphviz dot file either (a) calls the graphviz command "dot" to turn it into a SVG and remove the dotfile (default), or (b) if no_graphviz is True, just output the graphviz dot file Args: a NetworkX DiGraph the settings dictionary a filename (a default i...
sakelib/acts.py
def visualize(G, settings, filename="dependencies", no_graphviz=False): """ Uses networkX to draw a graphviz dot file either (a) calls the graphviz command "dot" to turn it into a SVG and remove the dotfile (default), or (b) if no_graphviz is True, just output the graphviz dot file Args: ...
def visualize(G, settings, filename="dependencies", no_graphviz=False): """ Uses networkX to draw a graphviz dot file either (a) calls the graphviz command "dot" to turn it into a SVG and remove the dotfile (default), or (b) if no_graphviz is True, just output the graphviz dot file Args: ...
[ "Uses", "networkX", "to", "draw", "a", "graphviz", "dot", "file", "either", "(", "a", ")", "calls", "the", "graphviz", "command", "dot", "to", "turn", "it", "into", "a", "SVG", "and", "remove", "the", "dotfile", "(", "default", ")", "or", "(", "b", "...
tonyfischetti/sake
python
https://github.com/tonyfischetti/sake/blob/b7ad20fe8e7137db99a20ac06b8da26492601b00/sakelib/acts.py#L626-L675
[ "def", "visualize", "(", "G", ",", "settings", ",", "filename", "=", "\"dependencies\"", ",", "no_graphviz", "=", "False", ")", ":", "error", "=", "settings", "[", "\"error\"", "]", "if", "no_graphviz", ":", "write_dot_file", "(", "G", ",", "filename", ")"...
b7ad20fe8e7137db99a20ac06b8da26492601b00
valid
itertable
Auxiliary function for iterating over a data table.
src/pyclts/util.py
def itertable(table): """Auxiliary function for iterating over a data table.""" for item in table: res = { k.lower(): nfd(v) if isinstance(v, text_type) else v for k, v in item.items()} for extra in res.pop('extra', []): k, _, v = extra.partition(':') res[k.st...
def itertable(table): """Auxiliary function for iterating over a data table.""" for item in table: res = { k.lower(): nfd(v) if isinstance(v, text_type) else v for k, v in item.items()} for extra in res.pop('extra', []): k, _, v = extra.partition(':') res[k.st...
[ "Auxiliary", "function", "for", "iterating", "over", "a", "data", "table", "." ]
cldf/clts
python
https://github.com/cldf/clts/blob/2798554c9c4e668bce0e4f5b0d91cf03c2d7c13a/src/pyclts/util.py#L73-L81
[ "def", "itertable", "(", "table", ")", ":", "for", "item", "in", "table", ":", "res", "=", "{", "k", ".", "lower", "(", ")", ":", "nfd", "(", "v", ")", "if", "isinstance", "(", "v", ",", "text_type", ")", "else", "v", "for", "k", ",", "v", "i...
2798554c9c4e668bce0e4f5b0d91cf03c2d7c13a
valid
_make_package
Prepare transcriptiondata from the transcription sources.
src/pyclts/__main__.py
def _make_package(args): # pragma: no cover """Prepare transcriptiondata from the transcription sources.""" from lingpy.sequence.sound_classes import token2class from lingpy.data import Model columns = ['LATEX', 'FEATURES', 'SOUND', 'IMAGE', 'COUNT', 'NOTE'] bipa = TranscriptionSystem('bipa') ...
def _make_package(args): # pragma: no cover """Prepare transcriptiondata from the transcription sources.""" from lingpy.sequence.sound_classes import token2class from lingpy.data import Model columns = ['LATEX', 'FEATURES', 'SOUND', 'IMAGE', 'COUNT', 'NOTE'] bipa = TranscriptionSystem('bipa') ...
[ "Prepare", "transcriptiondata", "from", "the", "transcription", "sources", "." ]
cldf/clts
python
https://github.com/cldf/clts/blob/2798554c9c4e668bce0e4f5b0d91cf03c2d7c13a/src/pyclts/__main__.py#L45-L97
[ "def", "_make_package", "(", "args", ")", ":", "# pragma: no cover", "from", "lingpy", ".", "sequence", ".", "sound_classes", "import", "token2class", "from", "lingpy", ".", "data", "import", "Model", "columns", "=", "[", "'LATEX'", ",", "'FEATURES'", ",", "'S...
2798554c9c4e668bce0e4f5b0d91cf03c2d7c13a
valid
is_valid_sound
Check the consistency of a given transcription system conversino
src/pyclts/models.py
def is_valid_sound(sound, ts): """Check the consistency of a given transcription system conversino""" if isinstance(sound, (Marker, UnknownSound)): return False s1 = ts[sound.name] s2 = ts[sound.s] return s1.name == s2.name and s1.s == s2.s
def is_valid_sound(sound, ts): """Check the consistency of a given transcription system conversino""" if isinstance(sound, (Marker, UnknownSound)): return False s1 = ts[sound.name] s2 = ts[sound.s] return s1.name == s2.name and s1.s == s2.s
[ "Check", "the", "consistency", "of", "a", "given", "transcription", "system", "conversino" ]
cldf/clts
python
https://github.com/cldf/clts/blob/2798554c9c4e668bce0e4f5b0d91cf03c2d7c13a/src/pyclts/models.py#L42-L48
[ "def", "is_valid_sound", "(", "sound", ",", "ts", ")", ":", "if", "isinstance", "(", "sound", ",", "(", "Marker", ",", "UnknownSound", ")", ")", ":", "return", "False", "s1", "=", "ts", "[", "sound", ".", "name", "]", "s2", "=", "ts", "[", "sound",...
2798554c9c4e668bce0e4f5b0d91cf03c2d7c13a
valid
TranscriptionData.resolve_sound
Function tries to identify a sound in the data. Notes ----- The function tries to resolve sounds to take a sound with less complex features in order to yield the next approximate sound class, if the transcription data are sound classes.
src/pyclts/transcriptiondata.py
def resolve_sound(self, sound): """Function tries to identify a sound in the data. Notes ----- The function tries to resolve sounds to take a sound with less complex features in order to yield the next approximate sound class, if the transcription data are sound classes....
def resolve_sound(self, sound): """Function tries to identify a sound in the data. Notes ----- The function tries to resolve sounds to take a sound with less complex features in order to yield the next approximate sound class, if the transcription data are sound classes....
[ "Function", "tries", "to", "identify", "a", "sound", "in", "the", "data", "." ]
cldf/clts
python
https://github.com/cldf/clts/blob/2798554c9c4e668bce0e4f5b0d91cf03c2d7c13a/src/pyclts/transcriptiondata.py#L33-L45
[ "def", "resolve_sound", "(", "self", ",", "sound", ")", ":", "sound", "=", "sound", "if", "isinstance", "(", "sound", ",", "Sound", ")", "else", "self", ".", "system", "[", "sound", "]", "if", "sound", ".", "name", "in", "self", ".", "data", ":", "...
2798554c9c4e668bce0e4f5b0d91cf03c2d7c13a
valid
TranscriptionSystem._norm
Extended normalization: normalize by list of norm-characers, split by character "/".
src/pyclts/transcriptionsystem.py
def _norm(self, string): """Extended normalization: normalize by list of norm-characers, split by character "/".""" nstring = norm(string) if "/" in string: s, t = string.split('/') nstring = t return self.normalize(nstring)
def _norm(self, string): """Extended normalization: normalize by list of norm-characers, split by character "/".""" nstring = norm(string) if "/" in string: s, t = string.split('/') nstring = t return self.normalize(nstring)
[ "Extended", "normalization", ":", "normalize", "by", "list", "of", "norm", "-", "characers", "split", "by", "character", "/", "." ]
cldf/clts
python
https://github.com/cldf/clts/blob/2798554c9c4e668bce0e4f5b0d91cf03c2d7c13a/src/pyclts/transcriptionsystem.py#L119-L126
[ "def", "_norm", "(", "self", ",", "string", ")", ":", "nstring", "=", "norm", "(", "string", ")", "if", "\"/\"", "in", "string", ":", "s", ",", "t", "=", "string", ".", "split", "(", "'/'", ")", "nstring", "=", "t", "return", "self", ".", "normal...
2798554c9c4e668bce0e4f5b0d91cf03c2d7c13a
valid
TranscriptionSystem.normalize
Normalize the string according to normalization list
src/pyclts/transcriptionsystem.py
def normalize(self, string): """Normalize the string according to normalization list""" return ''.join([self._normalize.get(x, x) for x in nfd(string)])
def normalize(self, string): """Normalize the string according to normalization list""" return ''.join([self._normalize.get(x, x) for x in nfd(string)])
[ "Normalize", "the", "string", "according", "to", "normalization", "list" ]
cldf/clts
python
https://github.com/cldf/clts/blob/2798554c9c4e668bce0e4f5b0d91cf03c2d7c13a/src/pyclts/transcriptionsystem.py#L128-L130
[ "def", "normalize", "(", "self", ",", "string", ")", ":", "return", "''", ".", "join", "(", "[", "self", ".", "_normalize", ".", "get", "(", "x", ",", "x", ")", "for", "x", "in", "nfd", "(", "string", ")", "]", ")" ]
2798554c9c4e668bce0e4f5b0d91cf03c2d7c13a
valid
TranscriptionSystem._from_name
Parse a sound from its name
src/pyclts/transcriptionsystem.py
def _from_name(self, string): """Parse a sound from its name""" components = string.split(' ') if frozenset(components) in self.features: return self.features[frozenset(components)] rest, sound_class = components[:-1], components[-1] if sound_class in ['diphthong', 'c...
def _from_name(self, string): """Parse a sound from its name""" components = string.split(' ') if frozenset(components) in self.features: return self.features[frozenset(components)] rest, sound_class = components[:-1], components[-1] if sound_class in ['diphthong', 'c...
[ "Parse", "a", "sound", "from", "its", "name" ]
cldf/clts
python
https://github.com/cldf/clts/blob/2798554c9c4e668bce0e4f5b0d91cf03c2d7c13a/src/pyclts/transcriptionsystem.py#L132-L177
[ "def", "_from_name", "(", "self", ",", "string", ")", ":", "components", "=", "string", ".", "split", "(", "' '", ")", "if", "frozenset", "(", "components", ")", "in", "self", ".", "features", ":", "return", "self", ".", "features", "[", "frozenset", "...
2798554c9c4e668bce0e4f5b0d91cf03c2d7c13a
valid
TranscriptionSystem._parse
Parse a string and return its features. :param string: A one-symbol string in NFD Notes ----- Strategy is rather simple: we determine the base part of a string and then search left and right of this part for the additional features as expressed by the diacritics. Fails ...
src/pyclts/transcriptionsystem.py
def _parse(self, string): """Parse a string and return its features. :param string: A one-symbol string in NFD Notes ----- Strategy is rather simple: we determine the base part of a string and then search left and right of this part for the additional features as ...
def _parse(self, string): """Parse a string and return its features. :param string: A one-symbol string in NFD Notes ----- Strategy is rather simple: we determine the base part of a string and then search left and right of this part for the additional features as ...
[ "Parse", "a", "string", "and", "return", "its", "features", "." ]
cldf/clts
python
https://github.com/cldf/clts/blob/2798554c9c4e668bce0e4f5b0d91cf03c2d7c13a/src/pyclts/transcriptionsystem.py#L179-L276
[ "def", "_parse", "(", "self", ",", "string", ")", ":", "nstring", "=", "self", ".", "_norm", "(", "string", ")", "# check whether sound is in self.sounds", "if", "nstring", "in", "self", ".", "sounds", ":", "sound", "=", "self", ".", "sounds", "[", "nstrin...
2798554c9c4e668bce0e4f5b0d91cf03c2d7c13a
valid
SoundClasses.resolve_sound
Function tries to identify a sound in the data. Notes ----- The function tries to resolve sounds to take a sound with less complex features in order to yield the next approximate sound class, if the transcription data are sound classes.
src/pyclts/soundclasses.py
def resolve_sound(self, sound): """Function tries to identify a sound in the data. Notes ----- The function tries to resolve sounds to take a sound with less complex features in order to yield the next approximate sound class, if the transcription data are sound classes....
def resolve_sound(self, sound): """Function tries to identify a sound in the data. Notes ----- The function tries to resolve sounds to take a sound with less complex features in order to yield the next approximate sound class, if the transcription data are sound classes....
[ "Function", "tries", "to", "identify", "a", "sound", "in", "the", "data", "." ]
cldf/clts
python
https://github.com/cldf/clts/blob/2798554c9c4e668bce0e4f5b0d91cf03c2d7c13a/src/pyclts/soundclasses.py#L27-L51
[ "def", "resolve_sound", "(", "self", ",", "sound", ")", ":", "sound", "=", "sound", "if", "isinstance", "(", "sound", ",", "Symbol", ")", "else", "self", ".", "system", "[", "sound", "]", "if", "sound", ".", "name", "in", "self", ".", "data", ":", ...
2798554c9c4e668bce0e4f5b0d91cf03c2d7c13a
valid
ipfn.ipfn_np
Runs the ipfn method from a matrix m, aggregates/marginals and the dimension(s) preserved. For example: from ipfn import ipfn import numpy as np m = np.array([[8., 4., 6., 7.], [3., 6., 5., 2.], [9., 11., 3., 1.]], ) xip = np.array([20., 18., 22.]) xpj = np.array([18., 16...
ipfn/ipfn.py
def ipfn_np(self, m, aggregates, dimensions, weight_col='total'): """ Runs the ipfn method from a matrix m, aggregates/marginals and the dimension(s) preserved. For example: from ipfn import ipfn import numpy as np m = np.array([[8., 4., 6., 7.], [3., 6., 5., 2.], [9., 11...
def ipfn_np(self, m, aggregates, dimensions, weight_col='total'): """ Runs the ipfn method from a matrix m, aggregates/marginals and the dimension(s) preserved. For example: from ipfn import ipfn import numpy as np m = np.array([[8., 4., 6., 7.], [3., 6., 5., 2.], [9., 11...
[ "Runs", "the", "ipfn", "method", "from", "a", "matrix", "m", "aggregates", "/", "marginals", "and", "the", "dimension", "(", "s", ")", "preserved", ".", "For", "example", ":", "from", "ipfn", "import", "ipfn", "import", "numpy", "as", "np", "m", "=", "...
Dirguis/ipfn
python
https://github.com/Dirguis/ipfn/blob/0a896ea395664515c5a424b69043937aad1d5567/ipfn/ipfn.py#L60-L134
[ "def", "ipfn_np", "(", "self", ",", "m", ",", "aggregates", ",", "dimensions", ",", "weight_col", "=", "'total'", ")", ":", "steps", "=", "len", "(", "aggregates", ")", "dim", "=", "len", "(", "m", ".", "shape", ")", "product_elem", "=", "[", "]", ...
0a896ea395664515c5a424b69043937aad1d5567
valid
ipfn.ipfn_df
Runs the ipfn method from a dataframe df, aggregates/marginals and the dimension(s) preserved. For example: from ipfn import ipfn import pandas as pd age = [30, 30, 30, 30, 40, 40, 40, 40, 50, 50, 50, 50] distance = [10,20,30,40,10,20,30,40,10,20,30,40] m = [8., 4., 6., 7...
ipfn/ipfn.py
def ipfn_df(self, df, aggregates, dimensions, weight_col='total'): """ Runs the ipfn method from a dataframe df, aggregates/marginals and the dimension(s) preserved. For example: from ipfn import ipfn import pandas as pd age = [30, 30, 30, 30, 40, 40, 40, 40, 50, 50, 50, ...
def ipfn_df(self, df, aggregates, dimensions, weight_col='total'): """ Runs the ipfn method from a dataframe df, aggregates/marginals and the dimension(s) preserved. For example: from ipfn import ipfn import pandas as pd age = [30, 30, 30, 30, 40, 40, 40, 40, 50, 50, 50, ...
[ "Runs", "the", "ipfn", "method", "from", "a", "dataframe", "df", "aggregates", "/", "marginals", "and", "the", "dimension", "(", "s", ")", "preserved", ".", "For", "example", ":", "from", "ipfn", "import", "ipfn", "import", "pandas", "as", "pd", "age", "...
Dirguis/ipfn
python
https://github.com/Dirguis/ipfn/blob/0a896ea395664515c5a424b69043937aad1d5567/ipfn/ipfn.py#L136-L221
[ "def", "ipfn_df", "(", "self", ",", "df", ",", "aggregates", ",", "dimensions", ",", "weight_col", "=", "'total'", ")", ":", "steps", "=", "len", "(", "aggregates", ")", "tables", "=", "[", "df", "]", "for", "inc", "in", "range", "(", "steps", "-", ...
0a896ea395664515c5a424b69043937aad1d5567
valid
ipfn.iteration
Runs the ipfn algorithm. Automatically detects of working with numpy ndarray or pandas dataframes.
ipfn/ipfn.py
def iteration(self): """ Runs the ipfn algorithm. Automatically detects of working with numpy ndarray or pandas dataframes. """ i = 0 conv = np.inf old_conv = -np.inf conv_list = [] m = self.original # If the original data input is in pandas Data...
def iteration(self): """ Runs the ipfn algorithm. Automatically detects of working with numpy ndarray or pandas dataframes. """ i = 0 conv = np.inf old_conv = -np.inf conv_list = [] m = self.original # If the original data input is in pandas Data...
[ "Runs", "the", "ipfn", "algorithm", ".", "Automatically", "detects", "of", "working", "with", "numpy", "ndarray", "or", "pandas", "dataframes", "." ]
Dirguis/ipfn
python
https://github.com/Dirguis/ipfn/blob/0a896ea395664515c5a424b69043937aad1d5567/ipfn/ipfn.py#L223-L268
[ "def", "iteration", "(", "self", ")", ":", "i", "=", "0", "conv", "=", "np", ".", "inf", "old_conv", "=", "-", "np", ".", "inf", "conv_list", "=", "[", "]", "m", "=", "self", ".", "original", "# If the original data input is in pandas DataFrame format", "i...
0a896ea395664515c5a424b69043937aad1d5567
valid
Link.render
Render link as HTML output tag <a>.
table/columns/linkcolumn.py
def render(self, obj): """ Render link as HTML output tag <a>. """ self.obj = obj attrs = ' '.join([ '%s="%s"' % (attr_name, attr.resolve(obj)) if isinstance(attr, Accessor) else '%s="%s"' % (attr_name, attr) for attr_name, attr in self.att...
def render(self, obj): """ Render link as HTML output tag <a>. """ self.obj = obj attrs = ' '.join([ '%s="%s"' % (attr_name, attr.resolve(obj)) if isinstance(attr, Accessor) else '%s="%s"' % (attr_name, attr) for attr_name, attr in self.att...
[ "Render", "link", "as", "HTML", "output", "tag", "<a", ">", "." ]
shymonk/django-datatable
python
https://github.com/shymonk/django-datatable/blob/f20a6ed2ce31aa7488ff85b4b0e80fe1ad94ec44/table/columns/linkcolumn.py#L85-L95
[ "def", "render", "(", "self", ",", "obj", ")", ":", "self", ".", "obj", "=", "obj", "attrs", "=", "' '", ".", "join", "(", "[", "'%s=\"%s\"'", "%", "(", "attr_name", ",", "attr", ".", "resolve", "(", "obj", ")", ")", "if", "isinstance", "(", "att...
f20a6ed2ce31aa7488ff85b4b0e80fe1ad94ec44
valid
Accessor.resolve
Return an object described by the accessor by traversing the attributes of context.
table/utils.py
def resolve(self, context, quiet=True): """ Return an object described by the accessor by traversing the attributes of context. """ try: obj = context for level in self.levels: if isinstance(obj, dict): obj = ...
def resolve(self, context, quiet=True): """ Return an object described by the accessor by traversing the attributes of context. """ try: obj = context for level in self.levels: if isinstance(obj, dict): obj = ...
[ "Return", "an", "object", "described", "by", "the", "accessor", "by", "traversing", "the", "attributes", "of", "context", "." ]
shymonk/django-datatable
python
https://github.com/shymonk/django-datatable/blob/f20a6ed2ce31aa7488ff85b4b0e80fe1ad94ec44/table/utils.py#L17-L48
[ "def", "resolve", "(", "self", ",", "context", ",", "quiet", "=", "True", ")", ":", "try", ":", "obj", "=", "context", "for", "level", "in", "self", ".", "levels", ":", "if", "isinstance", "(", "obj", ",", "dict", ")", ":", "obj", "=", "obj", "["...
f20a6ed2ce31aa7488ff85b4b0e80fe1ad94ec44
valid
BaseTable.header_rows
[ [header1], [header3, header4] ]
table/tables.py
def header_rows(self): """ [ [header1], [header3, header4] ] """ # TO BE FIX: refactor header_rows = [] headers = [col.header for col in self.columns] for header in headers: if len(header_rows) <= header.row_order: header_rows.append([]...
def header_rows(self): """ [ [header1], [header3, header4] ] """ # TO BE FIX: refactor header_rows = [] headers = [col.header for col in self.columns] for header in headers: if len(header_rows) <= header.row_order: header_rows.append([]...
[ "[", "[", "header1", "]", "[", "header3", "header4", "]", "]" ]
shymonk/django-datatable
python
https://github.com/shymonk/django-datatable/blob/f20a6ed2ce31aa7488ff85b4b0e80fe1ad94ec44/table/tables.py#L40-L51
[ "def", "header_rows", "(", "self", ")", ":", "# TO BE FIX: refactor", "header_rows", "=", "[", "]", "headers", "=", "[", "col", ".", "header", "for", "col", "in", "self", ".", "columns", "]", "for", "header", "in", "headers", ":", "if", "len", "(", "he...
f20a6ed2ce31aa7488ff85b4b0e80fe1ad94ec44
valid
FeedDataView.get_context_data
Get context data for datatable server-side response. See http://www.datatables.net/usage/server-side
table/views.py
def get_context_data(self, **kwargs): """ Get context data for datatable server-side response. See http://www.datatables.net/usage/server-side """ sEcho = self.query_data["sEcho"] context = super(BaseListView, self).get_context_data(**kwargs) queryset = context["...
def get_context_data(self, **kwargs): """ Get context data for datatable server-side response. See http://www.datatables.net/usage/server-side """ sEcho = self.query_data["sEcho"] context = super(BaseListView, self).get_context_data(**kwargs) queryset = context["...
[ "Get", "context", "data", "for", "datatable", "server", "-", "side", "response", ".", "See", "http", ":", "//", "www", ".", "datatables", ".", "net", "/", "usage", "/", "server", "-", "side" ]
shymonk/django-datatable
python
https://github.com/shymonk/django-datatable/blob/f20a6ed2ce31aa7488ff85b4b0e80fe1ad94ec44/table/views.py#L119-L149
[ "def", "get_context_data", "(", "self", ",", "*", "*", "kwargs", ")", ":", "sEcho", "=", "self", ".", "query_data", "[", "\"sEcho\"", "]", "context", "=", "super", "(", "BaseListView", ",", "self", ")", ".", "get_context_data", "(", "*", "*", "kwargs", ...
f20a6ed2ce31aa7488ff85b4b0e80fe1ad94ec44
valid
InlineMonthsColumn.get_days_span
Calculate how many days the month spans.
table/columns/calendarcolumn.py
def get_days_span(self, month_index): """ Calculate how many days the month spans. """ is_first_month = month_index == 0 is_last_month = month_index == self.__len__() - 1 y = int(self.start_date.year + (self.start_date.month + month_index) / 13) m = int((self.sta...
def get_days_span(self, month_index): """ Calculate how many days the month spans. """ is_first_month = month_index == 0 is_last_month = month_index == self.__len__() - 1 y = int(self.start_date.year + (self.start_date.month + month_index) / 13) m = int((self.sta...
[ "Calculate", "how", "many", "days", "the", "month", "spans", "." ]
shymonk/django-datatable
python
https://github.com/shymonk/django-datatable/blob/f20a6ed2ce31aa7488ff85b4b0e80fe1ad94ec44/table/columns/calendarcolumn.py#L83-L102
[ "def", "get_days_span", "(", "self", ",", "month_index", ")", ":", "is_first_month", "=", "month_index", "==", "0", "is_last_month", "=", "month_index", "==", "self", ".", "__len__", "(", ")", "-", "1", "y", "=", "int", "(", "self", ".", "start_date", "....
f20a6ed2ce31aa7488ff85b4b0e80fe1ad94ec44
valid
_OPC._calculate_float
Returns an IEEE 754 float from an array of 4 bytes :param byte_array: Expects an array of 4 bytes :type byte_array: array :rtype: float
opc/__init__.py
def _calculate_float(self, byte_array): """Returns an IEEE 754 float from an array of 4 bytes :param byte_array: Expects an array of 4 bytes :type byte_array: array :rtype: float """ if len(byte_array) != 4: return None return struct.unpack('f', st...
def _calculate_float(self, byte_array): """Returns an IEEE 754 float from an array of 4 bytes :param byte_array: Expects an array of 4 bytes :type byte_array: array :rtype: float """ if len(byte_array) != 4: return None return struct.unpack('f', st...
[ "Returns", "an", "IEEE", "754", "float", "from", "an", "array", "of", "4", "bytes" ]
dhhagan/py-opc
python
https://github.com/dhhagan/py-opc/blob/2c8f19530fb64bf5fd4ee0d694a47850161ed8a7/opc/__init__.py#L117-L129
[ "def", "_calculate_float", "(", "self", ",", "byte_array", ")", ":", "if", "len", "(", "byte_array", ")", "!=", "4", ":", "return", "None", "return", "struct", ".", "unpack", "(", "'f'", ",", "struct", ".", "pack", "(", "'4B'", ",", "*", "byte_array", ...
2c8f19530fb64bf5fd4ee0d694a47850161ed8a7
valid
_OPC._calculate_period
calculate the sampling period in seconds
opc/__init__.py
def _calculate_period(self, vals): ''' calculate the sampling period in seconds ''' if len(vals) < 4: return None if self.firmware['major'] < 16: return ((vals[3] << 24) | (vals[2] << 16) | (vals[1] << 8) | vals[0]) / 12e6 else: return self._calculate...
def _calculate_period(self, vals): ''' calculate the sampling period in seconds ''' if len(vals) < 4: return None if self.firmware['major'] < 16: return ((vals[3] << 24) | (vals[2] << 16) | (vals[1] << 8) | vals[0]) / 12e6 else: return self._calculate...
[ "calculate", "the", "sampling", "period", "in", "seconds" ]
dhhagan/py-opc
python
https://github.com/dhhagan/py-opc/blob/2c8f19530fb64bf5fd4ee0d694a47850161ed8a7/opc/__init__.py#L171-L179
[ "def", "_calculate_period", "(", "self", ",", "vals", ")", ":", "if", "len", "(", "vals", ")", "<", "4", ":", "return", "None", "if", "self", ".", "firmware", "[", "'major'", "]", "<", "16", ":", "return", "(", "(", "vals", "[", "3", "]", "<<", ...
2c8f19530fb64bf5fd4ee0d694a47850161ed8a7
valid
_OPC.wait
Wait for the OPC to prepare itself for data transmission. On some devides this can take a few seconds :rtype: self :Example: >> alpha = opc.OPCN2(spi, debug=True).wait(check=200) >> alpha = opc.OPCN2(spi, debug=True, wait=True, check=200)
opc/__init__.py
def wait(self, **kwargs): """Wait for the OPC to prepare itself for data transmission. On some devides this can take a few seconds :rtype: self :Example: >> alpha = opc.OPCN2(spi, debug=True).wait(check=200) >> alpha = opc.OPCN2(spi, debug=True, wait=True, check=200) """ ...
def wait(self, **kwargs): """Wait for the OPC to prepare itself for data transmission. On some devides this can take a few seconds :rtype: self :Example: >> alpha = opc.OPCN2(spi, debug=True).wait(check=200) >> alpha = opc.OPCN2(spi, debug=True, wait=True, check=200) """ ...
[ "Wait", "for", "the", "OPC", "to", "prepare", "itself", "for", "data", "transmission", ".", "On", "some", "devides", "this", "can", "take", "a", "few", "seconds", ":", "rtype", ":", "self", ":", "Example", ":", ">>", "alpha", "=", "opc", ".", "OPCN2", ...
dhhagan/py-opc
python
https://github.com/dhhagan/py-opc/blob/2c8f19530fb64bf5fd4ee0d694a47850161ed8a7/opc/__init__.py#L181-L204
[ "def", "wait", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "not", "callable", "(", "self", ".", "on", ")", ":", "raise", "UserWarning", "(", "'Your device does not support the self.on function, try without wait'", ")", "if", "not", "callable", "(", "...
2c8f19530fb64bf5fd4ee0d694a47850161ed8a7
valid
_OPC.calculate_bin_boundary
Calculate the adc value that corresponds to a specific bin boundary diameter in microns. :param bb: Bin Boundary in microns :type bb: float :rtype: int
opc/__init__.py
def calculate_bin_boundary(self, bb): """Calculate the adc value that corresponds to a specific bin boundary diameter in microns. :param bb: Bin Boundary in microns :type bb: float :rtype: int """ return min(enumerate(OPC_LOOKUP), key = lambda x: abs(x[1] ...
def calculate_bin_boundary(self, bb): """Calculate the adc value that corresponds to a specific bin boundary diameter in microns. :param bb: Bin Boundary in microns :type bb: float :rtype: int """ return min(enumerate(OPC_LOOKUP), key = lambda x: abs(x[1] ...
[ "Calculate", "the", "adc", "value", "that", "corresponds", "to", "a", "specific", "bin", "boundary", "diameter", "in", "microns", "." ]
dhhagan/py-opc
python
https://github.com/dhhagan/py-opc/blob/2c8f19530fb64bf5fd4ee0d694a47850161ed8a7/opc/__init__.py#L223-L233
[ "def", "calculate_bin_boundary", "(", "self", ",", "bb", ")", ":", "return", "min", "(", "enumerate", "(", "OPC_LOOKUP", ")", ",", "key", "=", "lambda", "x", ":", "abs", "(", "x", "[", "1", "]", "-", "bb", ")", ")", "[", "0", "]" ]
2c8f19530fb64bf5fd4ee0d694a47850161ed8a7
valid
_OPC.read_info_string
Reads the information string for the OPC :rtype: string :Example: >>> alpha.read_info_string() 'OPC-N2 FirmwareVer=OPC-018.2....................BD'
opc/__init__.py
def read_info_string(self): """Reads the information string for the OPC :rtype: string :Example: >>> alpha.read_info_string() 'OPC-N2 FirmwareVer=OPC-018.2....................BD' """ infostring = [] # Send the command byte and sleep for 9 ms se...
def read_info_string(self): """Reads the information string for the OPC :rtype: string :Example: >>> alpha.read_info_string() 'OPC-N2 FirmwareVer=OPC-018.2....................BD' """ infostring = [] # Send the command byte and sleep for 9 ms se...
[ "Reads", "the", "information", "string", "for", "the", "OPC" ]
dhhagan/py-opc
python
https://github.com/dhhagan/py-opc/blob/2c8f19530fb64bf5fd4ee0d694a47850161ed8a7/opc/__init__.py#L235-L258
[ "def", "read_info_string", "(", "self", ")", ":", "infostring", "=", "[", "]", "# Send the command byte and sleep for 9 ms", "self", ".", "cnxn", ".", "xfer", "(", "[", "0x3F", "]", ")", "sleep", "(", "9e-3", ")", "# Read the info string by sending 60 empty bytes", ...
2c8f19530fb64bf5fd4ee0d694a47850161ed8a7
valid
_OPC.ping
Checks the connection between the Raspberry Pi and the OPC :rtype: Boolean
opc/__init__.py
def ping(self): """Checks the connection between the Raspberry Pi and the OPC :rtype: Boolean """ b = self.cnxn.xfer([0xCF])[0] # send the command byte sleep(0.1) return True if b == 0xF3 else False
def ping(self): """Checks the connection between the Raspberry Pi and the OPC :rtype: Boolean """ b = self.cnxn.xfer([0xCF])[0] # send the command byte sleep(0.1) return True if b == 0xF3 else False
[ "Checks", "the", "connection", "between", "the", "Raspberry", "Pi", "and", "the", "OPC" ]
dhhagan/py-opc
python
https://github.com/dhhagan/py-opc/blob/2c8f19530fb64bf5fd4ee0d694a47850161ed8a7/opc/__init__.py#L260-L269
[ "def", "ping", "(", "self", ")", ":", "b", "=", "self", ".", "cnxn", ".", "xfer", "(", "[", "0xCF", "]", ")", "[", "0", "]", "# send the command byte", "sleep", "(", "0.1", ")", "return", "True", "if", "b", "==", "0xF3", "else", "False" ]
2c8f19530fb64bf5fd4ee0d694a47850161ed8a7
valid
OPCN2.on
Turn ON the OPC (fan and laser) :rtype: boolean :Example: >>> alpha.on() True
opc/__init__.py
def on(self): """Turn ON the OPC (fan and laser) :rtype: boolean :Example: >>> alpha.on() True """ b1 = self.cnxn.xfer([0x03])[0] # send the command byte sleep(9e-3) # sleep for 9 ms b2, b3 = self.cnxn.xfer([...
def on(self): """Turn ON the OPC (fan and laser) :rtype: boolean :Example: >>> alpha.on() True """ b1 = self.cnxn.xfer([0x03])[0] # send the command byte sleep(9e-3) # sleep for 9 ms b2, b3 = self.cnxn.xfer([...
[ "Turn", "ON", "the", "OPC", "(", "fan", "and", "laser", ")" ]
dhhagan/py-opc
python
https://github.com/dhhagan/py-opc/blob/2c8f19530fb64bf5fd4ee0d694a47850161ed8a7/opc/__init__.py#L303-L318
[ "def", "on", "(", "self", ")", ":", "b1", "=", "self", ".", "cnxn", ".", "xfer", "(", "[", "0x03", "]", ")", "[", "0", "]", "# send the command byte", "sleep", "(", "9e-3", ")", "# sleep for 9 ms", "b2", ",", "b3", "=", "self", ".", "cnxn", ".", ...
2c8f19530fb64bf5fd4ee0d694a47850161ed8a7
valid
OPCN2.off
Turn OFF the OPC (fan and laser) :rtype: boolean :Example: >>> alpha.off() True
opc/__init__.py
def off(self): """Turn OFF the OPC (fan and laser) :rtype: boolean :Example: >>> alpha.off() True """ b1 = self.cnxn.xfer([0x03])[0] # send the command byte sleep(9e-3) # sleep for 9 ms b2 = self.cnxn.xfer([0...
def off(self): """Turn OFF the OPC (fan and laser) :rtype: boolean :Example: >>> alpha.off() True """ b1 = self.cnxn.xfer([0x03])[0] # send the command byte sleep(9e-3) # sleep for 9 ms b2 = self.cnxn.xfer([0...
[ "Turn", "OFF", "the", "OPC", "(", "fan", "and", "laser", ")" ]
dhhagan/py-opc
python
https://github.com/dhhagan/py-opc/blob/2c8f19530fb64bf5fd4ee0d694a47850161ed8a7/opc/__init__.py#L320-L335
[ "def", "off", "(", "self", ")", ":", "b1", "=", "self", ".", "cnxn", ".", "xfer", "(", "[", "0x03", "]", ")", "[", "0", "]", "# send the command byte", "sleep", "(", "9e-3", ")", "# sleep for 9 ms", "b2", "=", "self", ".", "cnxn", ".", "xfer", "(",...
2c8f19530fb64bf5fd4ee0d694a47850161ed8a7
valid
OPCN2.config
Read the configuration variables and returns them as a dictionary :rtype: dictionary :Example: >>> alpha.config() { 'BPD 13': 1.6499, 'BPD 12': 1.6499, 'BPD 11': 1.6499, 'BPD 10': 1.6499, 'BPD 15': 1.6499, 'BPD 14...
opc/__init__.py
def config(self): """Read the configuration variables and returns them as a dictionary :rtype: dictionary :Example: >>> alpha.config() { 'BPD 13': 1.6499, 'BPD 12': 1.6499, 'BPD 11': 1.6499, 'BPD 10': 1.6499, 'BPD 15'...
def config(self): """Read the configuration variables and returns them as a dictionary :rtype: dictionary :Example: >>> alpha.config() { 'BPD 13': 1.6499, 'BPD 12': 1.6499, 'BPD 11': 1.6499, 'BPD 10': 1.6499, 'BPD 15'...
[ "Read", "the", "configuration", "variables", "and", "returns", "them", "as", "a", "dictionary" ]
dhhagan/py-opc
python
https://github.com/dhhagan/py-opc/blob/2c8f19530fb64bf5fd4ee0d694a47850161ed8a7/opc/__init__.py#L337-L398
[ "def", "config", "(", "self", ")", ":", "config", "=", "[", "]", "data", "=", "{", "}", "# Send the command byte and sleep for 10 ms", "self", ".", "cnxn", ".", "xfer", "(", "[", "0x3C", "]", ")", "sleep", "(", "10e-3", ")", "# Read the config variables by s...
2c8f19530fb64bf5fd4ee0d694a47850161ed8a7
valid
OPCN2.config2
Read the second set of configuration variables and return as a dictionary. **NOTE: This method is supported by firmware v18+.** :rtype: dictionary :Example: >>> a.config2() { 'AMFanOnIdle': 0, 'AMIdleIntervalCount': 0, 'AMMaxDataArraysInFil...
opc/__init__.py
def config2(self): """Read the second set of configuration variables and return as a dictionary. **NOTE: This method is supported by firmware v18+.** :rtype: dictionary :Example: >>> a.config2() { 'AMFanOnIdle': 0, 'AMIdleIntervalCount': 0, ...
def config2(self): """Read the second set of configuration variables and return as a dictionary. **NOTE: This method is supported by firmware v18+.** :rtype: dictionary :Example: >>> a.config2() { 'AMFanOnIdle': 0, 'AMIdleIntervalCount': 0, ...
[ "Read", "the", "second", "set", "of", "configuration", "variables", "and", "return", "as", "a", "dictionary", "." ]
dhhagan/py-opc
python
https://github.com/dhhagan/py-opc/blob/2c8f19530fb64bf5fd4ee0d694a47850161ed8a7/opc/__init__.py#L401-L441
[ "def", "config2", "(", "self", ")", ":", "config", "=", "[", "]", "data", "=", "{", "}", "# Send the command byte and sleep for 10 ms", "self", ".", "cnxn", ".", "xfer", "(", "[", "0x3D", "]", ")", "sleep", "(", "10e-3", ")", "# Read the config variables by ...
2c8f19530fb64bf5fd4ee0d694a47850161ed8a7
valid
OPCN2.histogram
Read and reset the histogram. As of v1.3.0, histogram values are reported in particle number concentration (#/cc) by default. :param number_concentration: If true, histogram bins are reported in number concentration vs. raw values. :type number_concentration: boolean :rtype: dictionar...
opc/__init__.py
def histogram(self, number_concentration=True): """Read and reset the histogram. As of v1.3.0, histogram values are reported in particle number concentration (#/cc) by default. :param number_concentration: If true, histogram bins are reported in number concentration vs. raw values. :ty...
def histogram(self, number_concentration=True): """Read and reset the histogram. As of v1.3.0, histogram values are reported in particle number concentration (#/cc) by default. :param number_concentration: If true, histogram bins are reported in number concentration vs. raw values. :ty...
[ "Read", "and", "reset", "the", "histogram", ".", "As", "of", "v1", ".", "3", ".", "0", "histogram", "values", "are", "reported", "in", "particle", "number", "concentration", "(", "#", "/", "cc", ")", "by", "default", "." ]
dhhagan/py-opc
python
https://github.com/dhhagan/py-opc/blob/2c8f19530fb64bf5fd4ee0d694a47850161ed8a7/opc/__init__.py#L472-L610
[ "def", "histogram", "(", "self", ",", "number_concentration", "=", "True", ")", ":", "resp", "=", "[", "]", "data", "=", "{", "}", "# Send the command byte", "self", ".", "cnxn", ".", "xfer", "(", "[", "0x30", "]", ")", "# Wait 10 ms", "sleep", "(", "1...
2c8f19530fb64bf5fd4ee0d694a47850161ed8a7
valid
OPCN2.save_config_variables
Save the configuration variables in non-volatile memory. This method should be used in conjuction with *write_config_variables*. :rtype: boolean :Example: >>> alpha.save_config_variables() True
opc/__init__.py
def save_config_variables(self): """Save the configuration variables in non-volatile memory. This method should be used in conjuction with *write_config_variables*. :rtype: boolean :Example: >>> alpha.save_config_variables() True """ command = 0x43 ...
def save_config_variables(self): """Save the configuration variables in non-volatile memory. This method should be used in conjuction with *write_config_variables*. :rtype: boolean :Example: >>> alpha.save_config_variables() True """ command = 0x43 ...
[ "Save", "the", "configuration", "variables", "in", "non", "-", "volatile", "memory", ".", "This", "method", "should", "be", "used", "in", "conjuction", "with", "*", "write_config_variables", "*", "." ]
dhhagan/py-opc
python
https://github.com/dhhagan/py-opc/blob/2c8f19530fb64bf5fd4ee0d694a47850161ed8a7/opc/__init__.py#L612-L642
[ "def", "save_config_variables", "(", "self", ")", ":", "command", "=", "0x43", "byte_list", "=", "[", "0x3F", ",", "0x3C", ",", "0x3F", ",", "0x3C", ",", "0x43", "]", "success", "=", "[", "0xF3", ",", "0x43", ",", "0x3F", ",", "0x3C", ",", "0x3F", ...
2c8f19530fb64bf5fd4ee0d694a47850161ed8a7
valid
OPCN2.set_fan_power
Set only the Fan power. :param power: Fan power value as an integer between 0-255. :type power: int :rtype: boolean :Example: >>> alpha.set_fan_power(255) True
opc/__init__.py
def set_fan_power(self, power): """Set only the Fan power. :param power: Fan power value as an integer between 0-255. :type power: int :rtype: boolean :Example: >>> alpha.set_fan_power(255) True """ # Check to make sure the value is a single b...
def set_fan_power(self, power): """Set only the Fan power. :param power: Fan power value as an integer between 0-255. :type power: int :rtype: boolean :Example: >>> alpha.set_fan_power(255) True """ # Check to make sure the value is a single b...
[ "Set", "only", "the", "Fan", "power", "." ]
dhhagan/py-opc
python
https://github.com/dhhagan/py-opc/blob/2c8f19530fb64bf5fd4ee0d694a47850161ed8a7/opc/__init__.py#L658-L686
[ "def", "set_fan_power", "(", "self", ",", "power", ")", ":", "# Check to make sure the value is a single byte", "if", "power", ">", "255", ":", "raise", "ValueError", "(", "\"The fan power should be a single byte (0-255).\"", ")", "# Send the command byte and wait 10 ms", "a"...
2c8f19530fb64bf5fd4ee0d694a47850161ed8a7
valid
OPCN2.toggle_laser
Toggle the power state of the laser. :param state: Boolean state of the laser :type state: boolean :rtype: boolean :Example: >>> alpha.toggle_laser(True) True
opc/__init__.py
def toggle_laser(self, state): """Toggle the power state of the laser. :param state: Boolean state of the laser :type state: boolean :rtype: boolean :Example: >>> alpha.toggle_laser(True) True """ # Send the command byte and wait 10 ms ...
def toggle_laser(self, state): """Toggle the power state of the laser. :param state: Boolean state of the laser :type state: boolean :rtype: boolean :Example: >>> alpha.toggle_laser(True) True """ # Send the command byte and wait 10 ms ...
[ "Toggle", "the", "power", "state", "of", "the", "laser", "." ]
dhhagan/py-opc
python
https://github.com/dhhagan/py-opc/blob/2c8f19530fb64bf5fd4ee0d694a47850161ed8a7/opc/__init__.py#L719-L747
[ "def", "toggle_laser", "(", "self", ",", "state", ")", ":", "# Send the command byte and wait 10 ms", "a", "=", "self", ".", "cnxn", ".", "xfer", "(", "[", "0x03", "]", ")", "[", "0", "]", "sleep", "(", "10e-3", ")", "# If state is true, turn the laser ON, els...
2c8f19530fb64bf5fd4ee0d694a47850161ed8a7
valid
OPCN2.read_pot_status
Read the status of the digital pot. Firmware v18+ only. The return value is a dictionary containing the following as unsigned 8-bit integers: FanON, LaserON, FanDACVal, LaserDACVal. :rtype: dict :Example: >>> alpha.read_pot_status() { 'LaserDACVal': 230, ...
opc/__init__.py
def read_pot_status(self): """Read the status of the digital pot. Firmware v18+ only. The return value is a dictionary containing the following as unsigned 8-bit integers: FanON, LaserON, FanDACVal, LaserDACVal. :rtype: dict :Example: >>> alpha.read_pot_status() ...
def read_pot_status(self): """Read the status of the digital pot. Firmware v18+ only. The return value is a dictionary containing the following as unsigned 8-bit integers: FanON, LaserON, FanDACVal, LaserDACVal. :rtype: dict :Example: >>> alpha.read_pot_status() ...
[ "Read", "the", "status", "of", "the", "digital", "pot", ".", "Firmware", "v18", "+", "only", ".", "The", "return", "value", "is", "a", "dictionary", "containing", "the", "following", "as", "unsigned", "8", "-", "bit", "integers", ":", "FanON", "LaserON", ...
dhhagan/py-opc
python
https://github.com/dhhagan/py-opc/blob/2c8f19530fb64bf5fd4ee0d694a47850161ed8a7/opc/__init__.py#L780-L814
[ "def", "read_pot_status", "(", "self", ")", ":", "# Send the command byte and wait 10 ms", "a", "=", "self", ".", "cnxn", ".", "xfer", "(", "[", "0x13", "]", ")", "[", "0", "]", "sleep", "(", "10e-3", ")", "# Build an array of the results", "res", "=", "[", ...
2c8f19530fb64bf5fd4ee0d694a47850161ed8a7
valid
OPCN2.sn
Read the Serial Number string. This method is only available on OPC-N2 firmware versions 18+. :rtype: string :Example: >>> alpha.sn() 'OPC-N2 123456789'
opc/__init__.py
def sn(self): """Read the Serial Number string. This method is only available on OPC-N2 firmware versions 18+. :rtype: string :Example: >>> alpha.sn() 'OPC-N2 123456789' """ string = [] # Send the command byte and sleep for 9 ms self.cn...
def sn(self): """Read the Serial Number string. This method is only available on OPC-N2 firmware versions 18+. :rtype: string :Example: >>> alpha.sn() 'OPC-N2 123456789' """ string = [] # Send the command byte and sleep for 9 ms self.cn...
[ "Read", "the", "Serial", "Number", "string", ".", "This", "method", "is", "only", "available", "on", "OPC", "-", "N2", "firmware", "versions", "18", "+", "." ]
dhhagan/py-opc
python
https://github.com/dhhagan/py-opc/blob/2c8f19530fb64bf5fd4ee0d694a47850161ed8a7/opc/__init__.py#L817-L841
[ "def", "sn", "(", "self", ")", ":", "string", "=", "[", "]", "# Send the command byte and sleep for 9 ms", "self", ".", "cnxn", ".", "xfer", "(", "[", "0x10", "]", ")", "sleep", "(", "9e-3", ")", "# Read the info string by sending 60 empty bytes", "for", "i", ...
2c8f19530fb64bf5fd4ee0d694a47850161ed8a7
valid
OPCN2.read_firmware
Read the firmware version of the OPC-N2. Firmware v18+ only. :rtype: dict :Example: >>> alpha.read_firmware() { 'major': 18, 'minor': 2, 'version': 18.2 }
opc/__init__.py
def read_firmware(self): """Read the firmware version of the OPC-N2. Firmware v18+ only. :rtype: dict :Example: >>> alpha.read_firmware() { 'major': 18, 'minor': 2, 'version': 18.2 } """ # Send the command byte and sl...
def read_firmware(self): """Read the firmware version of the OPC-N2. Firmware v18+ only. :rtype: dict :Example: >>> alpha.read_firmware() { 'major': 18, 'minor': 2, 'version': 18.2 } """ # Send the command byte and sl...
[ "Read", "the", "firmware", "version", "of", "the", "OPC", "-", "N2", ".", "Firmware", "v18", "+", "only", "." ]
dhhagan/py-opc
python
https://github.com/dhhagan/py-opc/blob/2c8f19530fb64bf5fd4ee0d694a47850161ed8a7/opc/__init__.py#L857-L883
[ "def", "read_firmware", "(", "self", ")", ":", "# Send the command byte and sleep for 9 ms", "self", ".", "cnxn", ".", "xfer", "(", "[", "0x12", "]", ")", "sleep", "(", "10e-3", ")", "self", ".", "firmware", "[", "'major'", "]", "=", "self", ".", "cnxn", ...
2c8f19530fb64bf5fd4ee0d694a47850161ed8a7
valid
OPCN2.pm
Read the PM data and reset the histogram **NOTE: This method is supported by firmware v18+.** :rtype: dictionary :Example: >>> alpha.pm() { 'PM1': 0.12, 'PM2.5': 0.24, 'PM10': 1.42 }
opc/__init__.py
def pm(self): """Read the PM data and reset the histogram **NOTE: This method is supported by firmware v18+.** :rtype: dictionary :Example: >>> alpha.pm() { 'PM1': 0.12, 'PM2.5': 0.24, 'PM10': 1.42 } """ res...
def pm(self): """Read the PM data and reset the histogram **NOTE: This method is supported by firmware v18+.** :rtype: dictionary :Example: >>> alpha.pm() { 'PM1': 0.12, 'PM2.5': 0.24, 'PM10': 1.42 } """ res...
[ "Read", "the", "PM", "data", "and", "reset", "the", "histogram" ]
dhhagan/py-opc
python
https://github.com/dhhagan/py-opc/blob/2c8f19530fb64bf5fd4ee0d694a47850161ed8a7/opc/__init__.py#L886-L924
[ "def", "pm", "(", "self", ")", ":", "resp", "=", "[", "]", "data", "=", "{", "}", "# Send the command byte", "self", ".", "cnxn", ".", "xfer", "(", "[", "0x32", "]", ")", "# Wait 10 ms", "sleep", "(", "10e-3", ")", "# read the histogram", "for", "i", ...
2c8f19530fb64bf5fd4ee0d694a47850161ed8a7
valid
OPCN1.on
Turn ON the OPC (fan and laser) :returns: boolean success state
opc/__init__.py
def on(self): """Turn ON the OPC (fan and laser) :returns: boolean success state """ b1 = self.cnxn.xfer([0x0C])[0] # send the command byte sleep(9e-3) # sleep for 9 ms return True if b1 == 0xF3 else False
def on(self): """Turn ON the OPC (fan and laser) :returns: boolean success state """ b1 = self.cnxn.xfer([0x0C])[0] # send the command byte sleep(9e-3) # sleep for 9 ms return True if b1 == 0xF3 else False
[ "Turn", "ON", "the", "OPC", "(", "fan", "and", "laser", ")" ]
dhhagan/py-opc
python
https://github.com/dhhagan/py-opc/blob/2c8f19530fb64bf5fd4ee0d694a47850161ed8a7/opc/__init__.py#L941-L949
[ "def", "on", "(", "self", ")", ":", "b1", "=", "self", ".", "cnxn", ".", "xfer", "(", "[", "0x0C", "]", ")", "[", "0", "]", "# send the command byte", "sleep", "(", "9e-3", ")", "# sleep for 9 ms", "return", "True", "if", "b1", "==", "0xF3", "else", ...
2c8f19530fb64bf5fd4ee0d694a47850161ed8a7
valid
OPCN1.off
Turn OFF the OPC (fan and laser) :returns: boolean success state
opc/__init__.py
def off(self): """Turn OFF the OPC (fan and laser) :returns: boolean success state """ b1 = self.cnxn.xfer([0x03])[0] # send the command byte sleep(9e-3) # sleep for 9 ms return True if b1 == 0xF3 else False
def off(self): """Turn OFF the OPC (fan and laser) :returns: boolean success state """ b1 = self.cnxn.xfer([0x03])[0] # send the command byte sleep(9e-3) # sleep for 9 ms return True if b1 == 0xF3 else False
[ "Turn", "OFF", "the", "OPC", "(", "fan", "and", "laser", ")" ]
dhhagan/py-opc
python
https://github.com/dhhagan/py-opc/blob/2c8f19530fb64bf5fd4ee0d694a47850161ed8a7/opc/__init__.py#L951-L959
[ "def", "off", "(", "self", ")", ":", "b1", "=", "self", ".", "cnxn", ".", "xfer", "(", "[", "0x03", "]", ")", "[", "0", "]", "# send the command byte", "sleep", "(", "9e-3", ")", "# sleep for 9 ms", "return", "True", "if", "b1", "==", "0xF3", "else",...
2c8f19530fb64bf5fd4ee0d694a47850161ed8a7
valid
OPCN1.read_gsc_sfr
Read the gain-scaling-coefficient and sample flow rate. :returns: dictionary containing GSC and SFR
opc/__init__.py
def read_gsc_sfr(self): """Read the gain-scaling-coefficient and sample flow rate. :returns: dictionary containing GSC and SFR """ config = [] data = {} # Send the command byte and sleep for 10 ms self.cnxn.xfer([0x33]) sleep(10e-3) # Read t...
def read_gsc_sfr(self): """Read the gain-scaling-coefficient and sample flow rate. :returns: dictionary containing GSC and SFR """ config = [] data = {} # Send the command byte and sleep for 10 ms self.cnxn.xfer([0x33]) sleep(10e-3) # Read t...
[ "Read", "the", "gain", "-", "scaling", "-", "coefficient", "and", "sample", "flow", "rate", "." ]
dhhagan/py-opc
python
https://github.com/dhhagan/py-opc/blob/2c8f19530fb64bf5fd4ee0d694a47850161ed8a7/opc/__init__.py#L961-L981
[ "def", "read_gsc_sfr", "(", "self", ")", ":", "config", "=", "[", "]", "data", "=", "{", "}", "# Send the command byte and sleep for 10 ms", "self", ".", "cnxn", ".", "xfer", "(", "[", "0x33", "]", ")", "sleep", "(", "10e-3", ")", "# Read the config variable...
2c8f19530fb64bf5fd4ee0d694a47850161ed8a7
valid
OPCN1.read_bin_boundaries
Return the bin boundaries. :returns: dictionary with 17 bin boundaries.
opc/__init__.py
def read_bin_boundaries(self): """Return the bin boundaries. :returns: dictionary with 17 bin boundaries. """ config = [] data = {} # Send the command byte and sleep for 10 ms self.cnxn.xfer([0x33]) sleep(10e-3) # Read the config variables b...
def read_bin_boundaries(self): """Return the bin boundaries. :returns: dictionary with 17 bin boundaries. """ config = [] data = {} # Send the command byte and sleep for 10 ms self.cnxn.xfer([0x33]) sleep(10e-3) # Read the config variables b...
[ "Return", "the", "bin", "boundaries", "." ]
dhhagan/py-opc
python
https://github.com/dhhagan/py-opc/blob/2c8f19530fb64bf5fd4ee0d694a47850161ed8a7/opc/__init__.py#L983-L1004
[ "def", "read_bin_boundaries", "(", "self", ")", ":", "config", "=", "[", "]", "data", "=", "{", "}", "# Send the command byte and sleep for 10 ms", "self", ".", "cnxn", ".", "xfer", "(", "[", "0x33", "]", ")", "sleep", "(", "10e-3", ")", "# Read the config v...
2c8f19530fb64bf5fd4ee0d694a47850161ed8a7
valid
OPCN1.read_bin_particle_density
Read the bin particle density :returns: float
opc/__init__.py
def read_bin_particle_density(self): """Read the bin particle density :returns: float """ config = [] # Send the command byte and sleep for 10 ms self.cnxn.xfer([0x33]) sleep(10e-3) # Read the config variables by sending 256 empty bytes for i in...
def read_bin_particle_density(self): """Read the bin particle density :returns: float """ config = [] # Send the command byte and sleep for 10 ms self.cnxn.xfer([0x33]) sleep(10e-3) # Read the config variables by sending 256 empty bytes for i in...
[ "Read", "the", "bin", "particle", "density" ]
dhhagan/py-opc
python
https://github.com/dhhagan/py-opc/blob/2c8f19530fb64bf5fd4ee0d694a47850161ed8a7/opc/__init__.py#L1013-L1031
[ "def", "read_bin_particle_density", "(", "self", ")", ":", "config", "=", "[", "]", "# Send the command byte and sleep for 10 ms", "self", ".", "cnxn", ".", "xfer", "(", "[", "0x33", "]", ")", "sleep", "(", "10e-3", ")", "# Read the config variables by sending 256 e...
2c8f19530fb64bf5fd4ee0d694a47850161ed8a7
valid
OPCN1.read_histogram
Read and reset the histogram. The expected return is a dictionary containing the counts per bin, MToF for bins 1, 3, 5, and 7, temperature, pressure, the sampling period, the checksum, PM1, PM2.5, and PM10. **NOTE:** The sampling period for the OPCN1 seems to be incorrect. :returns: di...
opc/__init__.py
def read_histogram(self): """Read and reset the histogram. The expected return is a dictionary containing the counts per bin, MToF for bins 1, 3, 5, and 7, temperature, pressure, the sampling period, the checksum, PM1, PM2.5, and PM10. **NOTE:** The sampling period for the OPCN1 seems t...
def read_histogram(self): """Read and reset the histogram. The expected return is a dictionary containing the counts per bin, MToF for bins 1, 3, 5, and 7, temperature, pressure, the sampling period, the checksum, PM1, PM2.5, and PM10. **NOTE:** The sampling period for the OPCN1 seems t...
[ "Read", "and", "reset", "the", "histogram", ".", "The", "expected", "return", "is", "a", "dictionary", "containing", "the", "counts", "per", "bin", "MToF", "for", "bins", "1", "3", "5", "and", "7", "temperature", "pressure", "the", "sampling", "period", "t...
dhhagan/py-opc
python
https://github.com/dhhagan/py-opc/blob/2c8f19530fb64bf5fd4ee0d694a47850161ed8a7/opc/__init__.py#L1041-L1103
[ "def", "read_histogram", "(", "self", ")", ":", "resp", "=", "[", "]", "data", "=", "{", "}", "# command byte", "command", "=", "0x30", "# Send the command byte", "self", ".", "cnxn", ".", "xfer", "(", "[", "command", "]", ")", "# Wait 10 ms", "sleep", "...
2c8f19530fb64bf5fd4ee0d694a47850161ed8a7
valid
HDLController.start
Starts HDLC controller's threads.
hdlcontroller/hdlcontroller.py
def start(self): """ Starts HDLC controller's threads. """ self.receiver = self.Receiver( self.read, self.write, self.send_lock, self.senders, self.frames_received, callback=self.receive_callback, fcs_na...
def start(self): """ Starts HDLC controller's threads. """ self.receiver = self.Receiver( self.read, self.write, self.send_lock, self.senders, self.frames_received, callback=self.receive_callback, fcs_na...
[ "Starts", "HDLC", "controller", "s", "threads", "." ]
SkypLabs/python-hdlc-controller
python
https://github.com/SkypLabs/python-hdlc-controller/blob/b7b964654728b2c11142a742e5d17821f1fe4788/hdlcontroller/hdlcontroller.py#L40-L55
[ "def", "start", "(", "self", ")", ":", "self", ".", "receiver", "=", "self", ".", "Receiver", "(", "self", ".", "read", ",", "self", ".", "write", ",", "self", ".", "send_lock", ",", "self", ".", "senders", ",", "self", ".", "frames_received", ",", ...
b7b964654728b2c11142a742e5d17821f1fe4788
valid
HDLController.stop
Stops HDLC controller's threads.
hdlcontroller/hdlcontroller.py
def stop(self): """ Stops HDLC controller's threads. """ if self.receiver != None: self.receiver.join() for s in self.senders.values(): s.join()
def stop(self): """ Stops HDLC controller's threads. """ if self.receiver != None: self.receiver.join() for s in self.senders.values(): s.join()
[ "Stops", "HDLC", "controller", "s", "threads", "." ]
SkypLabs/python-hdlc-controller
python
https://github.com/SkypLabs/python-hdlc-controller/blob/b7b964654728b2c11142a742e5d17821f1fe4788/hdlcontroller/hdlcontroller.py#L57-L66
[ "def", "stop", "(", "self", ")", ":", "if", "self", ".", "receiver", "!=", "None", ":", "self", ".", "receiver", ".", "join", "(", ")", "for", "s", "in", "self", ".", "senders", ".", "values", "(", ")", ":", "s", ".", "join", "(", ")" ]
b7b964654728b2c11142a742e5d17821f1fe4788
valid
HDLController.send
Sends a new data frame. This method will block until a new room is available for a new sender. This limit is determined by the size of the window.
hdlcontroller/hdlcontroller.py
def send(self, data): """ Sends a new data frame. This method will block until a new room is available for a new sender. This limit is determined by the size of the window. """ while len(self.senders) >= self.window: pass self.senders[self.new_seq_n...
def send(self, data): """ Sends a new data frame. This method will block until a new room is available for a new sender. This limit is determined by the size of the window. """ while len(self.senders) >= self.window: pass self.senders[self.new_seq_n...
[ "Sends", "a", "new", "data", "frame", "." ]
SkypLabs/python-hdlc-controller
python
https://github.com/SkypLabs/python-hdlc-controller/blob/b7b964654728b2c11142a742e5d17821f1fe4788/hdlcontroller/hdlcontroller.py#L110-L131
[ "def", "send", "(", "self", ",", "data", ")", ":", "while", "len", "(", "self", ".", "senders", ")", ">=", "self", ".", "window", ":", "pass", "self", ".", "senders", "[", "self", ".", "new_seq_no", "]", "=", "self", ".", "Sender", "(", "self", "...
b7b964654728b2c11142a742e5d17821f1fe4788
valid
Range.cmp
*Note: checks Range.start() only* Key: self = [], other = {} * [ {----]----} => -1 * {---[---} ] => 1 * [---] {---} => -1 * [---] same as {---} => 0 * [--{-}--] => -1
timestring/Range.py
def cmp(self, other): """*Note: checks Range.start() only* Key: self = [], other = {} * [ {----]----} => -1 * {---[---} ] => 1 * [---] {---} => -1 * [---] same as {---} => 0 * [--{-}--] => -1 """ if isinstance(other, Range):...
def cmp(self, other): """*Note: checks Range.start() only* Key: self = [], other = {} * [ {----]----} => -1 * {---[---} ] => 1 * [---] {---} => -1 * [---] same as {---} => 0 * [--{-}--] => -1 """ if isinstance(other, Range):...
[ "*", "Note", ":", "checks", "Range", ".", "start", "()", "only", "*", "Key", ":", "self", "=", "[]", "other", "=", "{}", "*", "[", "{", "----", "]", "----", "}", "=", ">", "-", "1", "*", "{", "---", "[", "---", "}", "]", "=", ">", "1", "*...
stevepeak/timestring
python
https://github.com/stevepeak/timestring/blob/c93d88f2e50d583ae973b985feffa92f70a515cf/timestring/Range.py#L264-L290
[ "def", "cmp", "(", "self", ",", "other", ")", ":", "if", "isinstance", "(", "other", ",", "Range", ")", ":", "# other has tz, I dont, so replace the tz", "start", "=", "self", ".", "start", ".", "replace", "(", "tzinfo", "=", "other", ".", "start", ".", ...
c93d88f2e50d583ae973b985feffa92f70a515cf
valid
Range.cut
Cuts this object from_start to the number requestd returns new instance
timestring/Range.py
def cut(self, by, from_start=True): """ Cuts this object from_start to the number requestd returns new instance """ s, e = copy(self.start), copy(self.end) if from_start: e = s + by else: s = e - by return Range(s, e)
def cut(self, by, from_start=True): """ Cuts this object from_start to the number requestd returns new instance """ s, e = copy(self.start), copy(self.end) if from_start: e = s + by else: s = e - by return Range(s, e)
[ "Cuts", "this", "object", "from_start", "to", "the", "number", "requestd", "returns", "new", "instance" ]
stevepeak/timestring
python
https://github.com/stevepeak/timestring/blob/c93d88f2e50d583ae973b985feffa92f70a515cf/timestring/Range.py#L337-L346
[ "def", "cut", "(", "self", ",", "by", ",", "from_start", "=", "True", ")", ":", "s", ",", "e", "=", "copy", "(", "self", ".", "start", ")", ",", "copy", "(", "self", ".", "end", ")", "if", "from_start", ":", "e", "=", "s", "+", "by", "else", ...
c93d88f2e50d583ae973b985feffa92f70a515cf
valid
Range.next
Returns a new instance of self times is not supported yet.
timestring/Range.py
def next(self, times=1): """Returns a new instance of self times is not supported yet. """ return Range(copy(self.end), self.end + self.elapse, tz=self.start.tz)
def next(self, times=1): """Returns a new instance of self times is not supported yet. """ return Range(copy(self.end), self.end + self.elapse, tz=self.start.tz)
[ "Returns", "a", "new", "instance", "of", "self", "times", "is", "not", "supported", "yet", "." ]
stevepeak/timestring
python
https://github.com/stevepeak/timestring/blob/c93d88f2e50d583ae973b985feffa92f70a515cf/timestring/Range.py#L353-L358
[ "def", "next", "(", "self", ",", "times", "=", "1", ")", ":", "return", "Range", "(", "copy", "(", "self", ".", "end", ")", ",", "self", ".", "end", "+", "self", ".", "elapse", ",", "tz", "=", "self", ".", "start", ".", "tz", ")" ]
c93d88f2e50d583ae973b985feffa92f70a515cf
valid
Range.prev
Returns a new instance of self times is not supported yet.
timestring/Range.py
def prev(self, times=1): """Returns a new instance of self times is not supported yet. """ return Range(self.start - self.elapse, copy(self.start), tz=self.start.tz)
def prev(self, times=1): """Returns a new instance of self times is not supported yet. """ return Range(self.start - self.elapse, copy(self.start), tz=self.start.tz)
[ "Returns", "a", "new", "instance", "of", "self", "times", "is", "not", "supported", "yet", "." ]
stevepeak/timestring
python
https://github.com/stevepeak/timestring/blob/c93d88f2e50d583ae973b985feffa92f70a515cf/timestring/Range.py#L360-L365
[ "def", "prev", "(", "self", ",", "times", "=", "1", ")", ":", "return", "Range", "(", "self", ".", "start", "-", "self", ".", "elapse", ",", "copy", "(", "self", ".", "start", ")", ",", "tz", "=", "self", ".", "start", ".", "tz", ")" ]
c93d88f2e50d583ae973b985feffa92f70a515cf
valid
Date.replace
Note returns a new Date obj
timestring/Date.py
def replace(self, **k): """Note returns a new Date obj""" if self.date != 'infinity': return Date(self.date.replace(**k)) else: return Date('infinity')
def replace(self, **k): """Note returns a new Date obj""" if self.date != 'infinity': return Date(self.date.replace(**k)) else: return Date('infinity')
[ "Note", "returns", "a", "new", "Date", "obj" ]
stevepeak/timestring
python
https://github.com/stevepeak/timestring/blob/c93d88f2e50d583ae973b985feffa92f70a515cf/timestring/Date.py#L292-L297
[ "def", "replace", "(", "self", ",", "*", "*", "k", ")", ":", "if", "self", ".", "date", "!=", "'infinity'", ":", "return", "Date", "(", "self", ".", "date", ".", "replace", "(", "*", "*", "k", ")", ")", "else", ":", "return", "Date", "(", "'inf...
c93d88f2e50d583ae973b985feffa92f70a515cf
valid
Date.adjust
Adjusts the time from kwargs to timedelta **Will change this object** return new copy of self
timestring/Date.py
def adjust(self, to): ''' Adjusts the time from kwargs to timedelta **Will change this object** return new copy of self ''' if self.date == 'infinity': return new = copy(self) if type(to) in (str, unicode): to = to.lower() ...
def adjust(self, to): ''' Adjusts the time from kwargs to timedelta **Will change this object** return new copy of self ''' if self.date == 'infinity': return new = copy(self) if type(to) in (str, unicode): to = to.lower() ...
[ "Adjusts", "the", "time", "from", "kwargs", "to", "timedelta", "**", "Will", "change", "this", "object", "**" ]
stevepeak/timestring
python
https://github.com/stevepeak/timestring/blob/c93d88f2e50d583ae973b985feffa92f70a515cf/timestring/Date.py#L299-L345
[ "def", "adjust", "(", "self", ",", "to", ")", ":", "if", "self", ".", "date", "==", "'infinity'", ":", "return", "new", "=", "copy", "(", "self", ")", "if", "type", "(", "to", ")", "in", "(", "str", ",", "unicode", ")", ":", "to", "=", "to", ...
c93d88f2e50d583ae973b985feffa92f70a515cf
valid
findall
Find all the timestrings within a block of text. >>> timestring.findall("once upon a time, about 3 weeks ago, there was a boy whom was born on august 15th at 7:20 am. epic.") [ ('3 weeks ago,', <timestring.Date 2014-02-09 00:00:00 4483019280>), ('august 15th at 7:20 am', <timestring.Date 2014-08-15 0...
timestring/__init__.py
def findall(text): """Find all the timestrings within a block of text. >>> timestring.findall("once upon a time, about 3 weeks ago, there was a boy whom was born on august 15th at 7:20 am. epic.") [ ('3 weeks ago,', <timestring.Date 2014-02-09 00:00:00 4483019280>), ('august 15th at 7:20 am', <ti...
def findall(text): """Find all the timestrings within a block of text. >>> timestring.findall("once upon a time, about 3 weeks ago, there was a boy whom was born on august 15th at 7:20 am. epic.") [ ('3 weeks ago,', <timestring.Date 2014-02-09 00:00:00 4483019280>), ('august 15th at 7:20 am', <ti...
[ "Find", "all", "the", "timestrings", "within", "a", "block", "of", "text", "." ]
stevepeak/timestring
python
https://github.com/stevepeak/timestring/blob/c93d88f2e50d583ae973b985feffa92f70a515cf/timestring/__init__.py#L54-L70
[ "def", "findall", "(", "text", ")", ":", "results", "=", "TIMESTRING_RE", ".", "findall", "(", "text", ")", "dates", "=", "[", "]", "for", "date", "in", "results", ":", "if", "re", ".", "compile", "(", "'((next|last)\\s(\\d+|couple(\\sof))\\s(weeks|months|quar...
c93d88f2e50d583ae973b985feffa92f70a515cf
valid
OAuthAuthentication.authenticate
Returns two-tuple of (user, token) if authentication succeeds, or None otherwise.
rest_framework_oauth/authentication.py
def authenticate(self, request): """ Returns two-tuple of (user, token) if authentication succeeds, or None otherwise. """ try: oauth_request = oauth_provider.utils.get_oauth_request(request) except oauth.Error as err: raise exceptions.Authenticati...
def authenticate(self, request): """ Returns two-tuple of (user, token) if authentication succeeds, or None otherwise. """ try: oauth_request = oauth_provider.utils.get_oauth_request(request) except oauth.Error as err: raise exceptions.Authenticati...
[ "Returns", "two", "-", "tuple", "of", "(", "user", "token", ")", "if", "authentication", "succeeds", "or", "None", "otherwise", "." ]
jpadilla/django-rest-framework-oauth
python
https://github.com/jpadilla/django-rest-framework-oauth/blob/e319b318c41edf93e121c58856bc4c744cdc6867/rest_framework_oauth/authentication.py#L37-L97
[ "def", "authenticate", "(", "self", ",", "request", ")", ":", "try", ":", "oauth_request", "=", "oauth_provider", ".", "utils", ".", "get_oauth_request", "(", "request", ")", "except", "oauth", ".", "Error", "as", "err", ":", "raise", "exceptions", ".", "A...
e319b318c41edf93e121c58856bc4c744cdc6867