id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
41,300 | rackerlabs/python-lunrclient | lunrclient/storage.py | StorageBackup.create | def create(self, volume_id, backup_id=None, timestamp=None):
"""
create a backup of a volume
"""
backup_id = backup_id or str(uuid.uuid4())
timestamp = timestamp or int(time())
return self.http_put('/volumes/%s/backups/%s' % (volume_id, backup_id),
... | python | def create(self, volume_id, backup_id=None, timestamp=None):
"""
create a backup of a volume
"""
backup_id = backup_id or str(uuid.uuid4())
timestamp = timestamp or int(time())
return self.http_put('/volumes/%s/backups/%s' % (volume_id, backup_id),
... | [
"def",
"create",
"(",
"self",
",",
"volume_id",
",",
"backup_id",
"=",
"None",
",",
"timestamp",
"=",
"None",
")",
":",
"backup_id",
"=",
"backup_id",
"or",
"str",
"(",
"uuid",
".",
"uuid4",
"(",
")",
")",
"timestamp",
"=",
"timestamp",
"or",
"int",
... | create a backup of a volume | [
"create",
"a",
"backup",
"of",
"a",
"volume"
] | f26a450a422600f492480bfa42cbee50a5c7016f | https://github.com/rackerlabs/python-lunrclient/blob/f26a450a422600f492480bfa42cbee50a5c7016f/lunrclient/storage.py#L123-L130 |
41,301 | ponty/confduino | confduino/boardlist.py | boards | def boards(hwpack='arduino'):
"""read boards from boards.txt.
:param core_package: 'all,'arduino',..
"""
bunch = read_properties(boards_txt(hwpack))
bunch_items = list(bunch.items())
# remove invalid boards
for bid, board in bunch_items:
if 'build' not in board.keys() or 'name' n... | python | def boards(hwpack='arduino'):
"""read boards from boards.txt.
:param core_package: 'all,'arduino',..
"""
bunch = read_properties(boards_txt(hwpack))
bunch_items = list(bunch.items())
# remove invalid boards
for bid, board in bunch_items:
if 'build' not in board.keys() or 'name' n... | [
"def",
"boards",
"(",
"hwpack",
"=",
"'arduino'",
")",
":",
"bunch",
"=",
"read_properties",
"(",
"boards_txt",
"(",
"hwpack",
")",
")",
"bunch_items",
"=",
"list",
"(",
"bunch",
".",
"items",
"(",
")",
")",
"# remove invalid boards",
"for",
"bid",
",",
... | read boards from boards.txt.
:param core_package: 'all,'arduino',.. | [
"read",
"boards",
"from",
"boards",
".",
"txt",
"."
] | f4c261e5e84997f145a8bdd001f471db74c9054b | https://github.com/ponty/confduino/blob/f4c261e5e84997f145a8bdd001f471db74c9054b/confduino/boardlist.py#L17-L33 |
41,302 | ponty/confduino | confduino/boardlist.py | board_names | def board_names(hwpack='arduino'):
"""return installed board names."""
ls = list(boards(hwpack).keys())
ls.sort()
return ls | python | def board_names(hwpack='arduino'):
"""return installed board names."""
ls = list(boards(hwpack).keys())
ls.sort()
return ls | [
"def",
"board_names",
"(",
"hwpack",
"=",
"'arduino'",
")",
":",
"ls",
"=",
"list",
"(",
"boards",
"(",
"hwpack",
")",
".",
"keys",
"(",
")",
")",
"ls",
".",
"sort",
"(",
")",
"return",
"ls"
] | return installed board names. | [
"return",
"installed",
"board",
"names",
"."
] | f4c261e5e84997f145a8bdd001f471db74c9054b | https://github.com/ponty/confduino/blob/f4c261e5e84997f145a8bdd001f471db74c9054b/confduino/boardlist.py#L36-L40 |
41,303 | ponty/confduino | confduino/boardlist.py | print_boards | def print_boards(hwpack='arduino', verbose=False):
"""print boards from boards.txt."""
if verbose:
pp(boards(hwpack))
else:
print('\n'.join(board_names(hwpack))) | python | def print_boards(hwpack='arduino', verbose=False):
"""print boards from boards.txt."""
if verbose:
pp(boards(hwpack))
else:
print('\n'.join(board_names(hwpack))) | [
"def",
"print_boards",
"(",
"hwpack",
"=",
"'arduino'",
",",
"verbose",
"=",
"False",
")",
":",
"if",
"verbose",
":",
"pp",
"(",
"boards",
"(",
"hwpack",
")",
")",
"else",
":",
"print",
"(",
"'\\n'",
".",
"join",
"(",
"board_names",
"(",
"hwpack",
")... | print boards from boards.txt. | [
"print",
"boards",
"from",
"boards",
".",
"txt",
"."
] | f4c261e5e84997f145a8bdd001f471db74c9054b | https://github.com/ponty/confduino/blob/f4c261e5e84997f145a8bdd001f471db74c9054b/confduino/boardlist.py#L44-L49 |
41,304 | ponty/confduino | confduino/libinstall.py | find_lib_dir | def find_lib_dir(root):
"""search for lib dir under root."""
root = path(root)
log.debug('files in dir: %s', root)
for x in root.walkfiles():
log.debug(' %s', x)
# only 1 dir in root? (example: github)
if not len(root.files()) and len(root.dirs()) == 1:
log.debug('go inside roo... | python | def find_lib_dir(root):
"""search for lib dir under root."""
root = path(root)
log.debug('files in dir: %s', root)
for x in root.walkfiles():
log.debug(' %s', x)
# only 1 dir in root? (example: github)
if not len(root.files()) and len(root.dirs()) == 1:
log.debug('go inside roo... | [
"def",
"find_lib_dir",
"(",
"root",
")",
":",
"root",
"=",
"path",
"(",
"root",
")",
"log",
".",
"debug",
"(",
"'files in dir: %s'",
",",
"root",
")",
"for",
"x",
"in",
"root",
".",
"walkfiles",
"(",
")",
":",
"log",
".",
"debug",
"(",
"' %s'",
",... | search for lib dir under root. | [
"search",
"for",
"lib",
"dir",
"under",
"root",
"."
] | f4c261e5e84997f145a8bdd001f471db74c9054b | https://github.com/ponty/confduino/blob/f4c261e5e84997f145a8bdd001f471db74c9054b/confduino/libinstall.py#L64-L119 |
41,305 | ponty/confduino | confduino/libinstall.py | move_examples | def move_examples(root, lib_dir):
"""find examples not under lib dir, and move into ``examples``"""
all_pde = files_multi_pattern(root, INO_PATTERNS)
lib_pde = files_multi_pattern(lib_dir, INO_PATTERNS)
stray_pde = all_pde.difference(lib_pde)
if len(stray_pde) and not len(lib_pde):
log.debug... | python | def move_examples(root, lib_dir):
"""find examples not under lib dir, and move into ``examples``"""
all_pde = files_multi_pattern(root, INO_PATTERNS)
lib_pde = files_multi_pattern(lib_dir, INO_PATTERNS)
stray_pde = all_pde.difference(lib_pde)
if len(stray_pde) and not len(lib_pde):
log.debug... | [
"def",
"move_examples",
"(",
"root",
",",
"lib_dir",
")",
":",
"all_pde",
"=",
"files_multi_pattern",
"(",
"root",
",",
"INO_PATTERNS",
")",
"lib_pde",
"=",
"files_multi_pattern",
"(",
"lib_dir",
",",
"INO_PATTERNS",
")",
"stray_pde",
"=",
"all_pde",
".",
"dif... | find examples not under lib dir, and move into ``examples`` | [
"find",
"examples",
"not",
"under",
"lib",
"dir",
"and",
"move",
"into",
"examples"
] | f4c261e5e84997f145a8bdd001f471db74c9054b | https://github.com/ponty/confduino/blob/f4c261e5e84997f145a8bdd001f471db74c9054b/confduino/libinstall.py#L130-L143 |
41,306 | ponty/confduino | confduino/libinstall.py | fix_examples_dir | def fix_examples_dir(lib_dir):
"""rename examples dir to ``examples``"""
for x in lib_dir.dirs():
if x.name.lower() == EXAMPLES:
return
for x in lib_dir.dirs():
if x.name.lower() == EXAMPLES:
_fix_dir(x)
return
for x in lib_dir.dirs():
if 'exam... | python | def fix_examples_dir(lib_dir):
"""rename examples dir to ``examples``"""
for x in lib_dir.dirs():
if x.name.lower() == EXAMPLES:
return
for x in lib_dir.dirs():
if x.name.lower() == EXAMPLES:
_fix_dir(x)
return
for x in lib_dir.dirs():
if 'exam... | [
"def",
"fix_examples_dir",
"(",
"lib_dir",
")",
":",
"for",
"x",
"in",
"lib_dir",
".",
"dirs",
"(",
")",
":",
"if",
"x",
".",
"name",
".",
"lower",
"(",
")",
"==",
"EXAMPLES",
":",
"return",
"for",
"x",
"in",
"lib_dir",
".",
"dirs",
"(",
")",
":"... | rename examples dir to ``examples`` | [
"rename",
"examples",
"dir",
"to",
"examples"
] | f4c261e5e84997f145a8bdd001f471db74c9054b | https://github.com/ponty/confduino/blob/f4c261e5e84997f145a8bdd001f471db74c9054b/confduino/libinstall.py#L152-L168 |
41,307 | ponty/confduino | confduino/libinstall.py | install_lib | def install_lib(url, replace_existing=False, fix_wprogram=True):
"""install library from web or local files system.
:param url: web address or file path
:param replace_existing: bool
:rtype: None
"""
d = tmpdir(tmpdir())
f = download(url)
Archive(f).extractall(d)
clean_dir(d)
... | python | def install_lib(url, replace_existing=False, fix_wprogram=True):
"""install library from web or local files system.
:param url: web address or file path
:param replace_existing: bool
:rtype: None
"""
d = tmpdir(tmpdir())
f = download(url)
Archive(f).extractall(d)
clean_dir(d)
... | [
"def",
"install_lib",
"(",
"url",
",",
"replace_existing",
"=",
"False",
",",
"fix_wprogram",
"=",
"True",
")",
":",
"d",
"=",
"tmpdir",
"(",
"tmpdir",
"(",
")",
")",
"f",
"=",
"download",
"(",
"url",
")",
"Archive",
"(",
"f",
")",
".",
"extractall",... | install library from web or local files system.
:param url: web address or file path
:param replace_existing: bool
:rtype: None | [
"install",
"library",
"from",
"web",
"or",
"local",
"files",
"system",
"."
] | f4c261e5e84997f145a8bdd001f471db74c9054b | https://github.com/ponty/confduino/blob/f4c261e5e84997f145a8bdd001f471db74c9054b/confduino/libinstall.py#L229-L263 |
41,308 | yougov/vr.common | vr/common/models.py | Host._init_supervisor_rpc | def _init_supervisor_rpc(self, rpc_or_port):
'''Initialize supervisor RPC.
Allow passing in an RPC connection, or a port number for
making one.
'''
if isinstance(rpc_or_port, int):
if self.username:
leader = 'http://{self.username}:{self.password}@'
... | python | def _init_supervisor_rpc(self, rpc_or_port):
'''Initialize supervisor RPC.
Allow passing in an RPC connection, or a port number for
making one.
'''
if isinstance(rpc_or_port, int):
if self.username:
leader = 'http://{self.username}:{self.password}@'
... | [
"def",
"_init_supervisor_rpc",
"(",
"self",
",",
"rpc_or_port",
")",
":",
"if",
"isinstance",
"(",
"rpc_or_port",
",",
"int",
")",
":",
"if",
"self",
".",
"username",
":",
"leader",
"=",
"'http://{self.username}:{self.password}@'",
"else",
":",
"leader",
"=",
... | Initialize supervisor RPC.
Allow passing in an RPC connection, or a port number for
making one. | [
"Initialize",
"supervisor",
"RPC",
"."
] | ca8ed0c50ba873fc51fdfeeaa25d3b8ec1b54eb4 | https://github.com/yougov/vr.common/blob/ca8ed0c50ba873fc51fdfeeaa25d3b8ec1b54eb4/vr/common/models.py#L113-L131 |
41,309 | yougov/vr.common | vr/common/models.py | Host._init_redis | def _init_redis(redis_spec):
"""
Return a StrictRedis instance or None based on redis_spec.
redis_spec may be None, a Redis URL, or a StrictRedis instance
"""
if not redis_spec:
return
if isinstance(redis_spec, six.string_types):
return redis.Stri... | python | def _init_redis(redis_spec):
"""
Return a StrictRedis instance or None based on redis_spec.
redis_spec may be None, a Redis URL, or a StrictRedis instance
"""
if not redis_spec:
return
if isinstance(redis_spec, six.string_types):
return redis.Stri... | [
"def",
"_init_redis",
"(",
"redis_spec",
")",
":",
"if",
"not",
"redis_spec",
":",
"return",
"if",
"isinstance",
"(",
"redis_spec",
",",
"six",
".",
"string_types",
")",
":",
"return",
"redis",
".",
"StrictRedis",
".",
"from_url",
"(",
"redis_spec",
")",
"... | Return a StrictRedis instance or None based on redis_spec.
redis_spec may be None, a Redis URL, or a StrictRedis instance | [
"Return",
"a",
"StrictRedis",
"instance",
"or",
"None",
"based",
"on",
"redis_spec",
"."
] | ca8ed0c50ba873fc51fdfeeaa25d3b8ec1b54eb4 | https://github.com/yougov/vr.common/blob/ca8ed0c50ba873fc51fdfeeaa25d3b8ec1b54eb4/vr/common/models.py#L134-L145 |
41,310 | yougov/vr.common | vr/common/models.py | Velociraptor._get_base | def _get_base():
"""
if 'deploy' resolves in this environment, use the hostname for which
that name resolves.
Override with 'VELOCIRAPTOR_URL'
"""
try:
name, _aliaslist, _addresslist = socket.gethostbyname_ex('deploy')
except socket.gaierror:
... | python | def _get_base():
"""
if 'deploy' resolves in this environment, use the hostname for which
that name resolves.
Override with 'VELOCIRAPTOR_URL'
"""
try:
name, _aliaslist, _addresslist = socket.gethostbyname_ex('deploy')
except socket.gaierror:
... | [
"def",
"_get_base",
"(",
")",
":",
"try",
":",
"name",
",",
"_aliaslist",
",",
"_addresslist",
"=",
"socket",
".",
"gethostbyname_ex",
"(",
"'deploy'",
")",
"except",
"socket",
".",
"gaierror",
":",
"name",
"=",
"'deploy'",
"fallback",
"=",
"'https://{name}/... | if 'deploy' resolves in this environment, use the hostname for which
that name resolves.
Override with 'VELOCIRAPTOR_URL' | [
"if",
"deploy",
"resolves",
"in",
"this",
"environment",
"use",
"the",
"hostname",
"for",
"which",
"that",
"name",
"resolves",
".",
"Override",
"with",
"VELOCIRAPTOR_URL"
] | ca8ed0c50ba873fc51fdfeeaa25d3b8ec1b54eb4 | https://github.com/yougov/vr.common/blob/ca8ed0c50ba873fc51fdfeeaa25d3b8ec1b54eb4/vr/common/models.py#L574-L585 |
41,311 | yougov/vr.common | vr/common/models.py | BaseResource.load_all | def load_all(cls, vr, params=None):
"""
Create instances of all objects found
"""
ob_docs = vr.query(cls.base, params)
return [cls(vr, ob) for ob in ob_docs] | python | def load_all(cls, vr, params=None):
"""
Create instances of all objects found
"""
ob_docs = vr.query(cls.base, params)
return [cls(vr, ob) for ob in ob_docs] | [
"def",
"load_all",
"(",
"cls",
",",
"vr",
",",
"params",
"=",
"None",
")",
":",
"ob_docs",
"=",
"vr",
".",
"query",
"(",
"cls",
".",
"base",
",",
"params",
")",
"return",
"[",
"cls",
"(",
"vr",
",",
"ob",
")",
"for",
"ob",
"in",
"ob_docs",
"]"
... | Create instances of all objects found | [
"Create",
"instances",
"of",
"all",
"objects",
"found"
] | ca8ed0c50ba873fc51fdfeeaa25d3b8ec1b54eb4 | https://github.com/yougov/vr.common/blob/ca8ed0c50ba873fc51fdfeeaa25d3b8ec1b54eb4/vr/common/models.py#L689-L694 |
41,312 | yougov/vr.common | vr/common/models.py | Swarm.dispatch | def dispatch(self, **changes):
"""
Patch the swarm with changes and then trigger the swarm.
"""
self.patch(**changes)
trigger_url = self._vr._build_url(self.resource_uri, 'swarm/')
resp = self._vr.session.post(trigger_url)
resp.raise_for_status()
try:
... | python | def dispatch(self, **changes):
"""
Patch the swarm with changes and then trigger the swarm.
"""
self.patch(**changes)
trigger_url = self._vr._build_url(self.resource_uri, 'swarm/')
resp = self._vr.session.post(trigger_url)
resp.raise_for_status()
try:
... | [
"def",
"dispatch",
"(",
"self",
",",
"*",
"*",
"changes",
")",
":",
"self",
".",
"patch",
"(",
"*",
"*",
"changes",
")",
"trigger_url",
"=",
"self",
".",
"_vr",
".",
"_build_url",
"(",
"self",
".",
"resource_uri",
",",
"'swarm/'",
")",
"resp",
"=",
... | Patch the swarm with changes and then trigger the swarm. | [
"Patch",
"the",
"swarm",
"with",
"changes",
"and",
"then",
"trigger",
"the",
"swarm",
"."
] | ca8ed0c50ba873fc51fdfeeaa25d3b8ec1b54eb4 | https://github.com/yougov/vr.common/blob/ca8ed0c50ba873fc51fdfeeaa25d3b8ec1b54eb4/vr/common/models.py#L738-L749 |
41,313 | yougov/vr.common | vr/common/models.py | Build.assemble | def assemble(self):
"""
Assemble a build
"""
if not self.created:
self.create()
# trigger the build
url = self._vr._build_url(self.resource_uri, 'build/')
resp = self._vr.session.post(url)
resp.raise_for_status() | python | def assemble(self):
"""
Assemble a build
"""
if not self.created:
self.create()
# trigger the build
url = self._vr._build_url(self.resource_uri, 'build/')
resp = self._vr.session.post(url)
resp.raise_for_status() | [
"def",
"assemble",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"created",
":",
"self",
".",
"create",
"(",
")",
"# trigger the build",
"url",
"=",
"self",
".",
"_vr",
".",
"_build_url",
"(",
"self",
".",
"resource_uri",
",",
"'build/'",
")",
"resp... | Assemble a build | [
"Assemble",
"a",
"build"
] | ca8ed0c50ba873fc51fdfeeaa25d3b8ec1b54eb4 | https://github.com/yougov/vr.common/blob/ca8ed0c50ba873fc51fdfeeaa25d3b8ec1b54eb4/vr/common/models.py#L782-L791 |
41,314 | koehlma/pygrooveshark | src/grooveshark/__init__.py | Connection._get_token | def _get_token(self):
'''
requests an communication token from Grooveshark
'''
self.session.token = self.request(
'getCommunicationToken',
{'secretKey': self.session.secret},
{'uuid': self.session.user,
'session': self.session.session,
... | python | def _get_token(self):
'''
requests an communication token from Grooveshark
'''
self.session.token = self.request(
'getCommunicationToken',
{'secretKey': self.session.secret},
{'uuid': self.session.user,
'session': self.session.session,
... | [
"def",
"_get_token",
"(",
"self",
")",
":",
"self",
".",
"session",
".",
"token",
"=",
"self",
".",
"request",
"(",
"'getCommunicationToken'",
",",
"{",
"'secretKey'",
":",
"self",
".",
"session",
".",
"secret",
"}",
",",
"{",
"'uuid'",
":",
"self",
".... | requests an communication token from Grooveshark | [
"requests",
"an",
"communication",
"token",
"from",
"Grooveshark"
] | 17673758ac12f54dc26ac879c30ea44f13b81057 | https://github.com/koehlma/pygrooveshark/blob/17673758ac12f54dc26ac879c30ea44f13b81057/src/grooveshark/__init__.py#L100-L113 |
41,315 | koehlma/pygrooveshark | src/grooveshark/__init__.py | Connection._request_token | def _request_token(self, method, client):
'''
generates a request token
'''
if time.time() - self.session.time > grooveshark.const.TOKEN_TIMEOUT:
self._get_token()
random_value = self._random_hex()
return random_value + hashlib.sha1((method + ':' + self.sessio... | python | def _request_token(self, method, client):
'''
generates a request token
'''
if time.time() - self.session.time > grooveshark.const.TOKEN_TIMEOUT:
self._get_token()
random_value = self._random_hex()
return random_value + hashlib.sha1((method + ':' + self.sessio... | [
"def",
"_request_token",
"(",
"self",
",",
"method",
",",
"client",
")",
":",
"if",
"time",
".",
"time",
"(",
")",
"-",
"self",
".",
"session",
".",
"time",
">",
"grooveshark",
".",
"const",
".",
"TOKEN_TIMEOUT",
":",
"self",
".",
"_get_token",
"(",
... | generates a request token | [
"generates",
"a",
"request",
"token"
] | 17673758ac12f54dc26ac879c30ea44f13b81057 | https://github.com/koehlma/pygrooveshark/blob/17673758ac12f54dc26ac879c30ea44f13b81057/src/grooveshark/__init__.py#L115-L122 |
41,316 | koehlma/pygrooveshark | src/grooveshark/__init__.py | Connection.request | def request(self, method, parameters, header):
'''
Grooveshark API request
'''
data = json.dumps({
'parameters': parameters,
'method': method,
'header': header})
request = urllib.Request(
'https://grooveshark.com/more.php?%s' % (met... | python | def request(self, method, parameters, header):
'''
Grooveshark API request
'''
data = json.dumps({
'parameters': parameters,
'method': method,
'header': header})
request = urllib.Request(
'https://grooveshark.com/more.php?%s' % (met... | [
"def",
"request",
"(",
"self",
",",
"method",
",",
"parameters",
",",
"header",
")",
":",
"data",
"=",
"json",
".",
"dumps",
"(",
"{",
"'parameters'",
":",
"parameters",
",",
"'method'",
":",
"method",
",",
"'header'",
":",
"header",
"}",
")",
"request... | Grooveshark API request | [
"Grooveshark",
"API",
"request"
] | 17673758ac12f54dc26ac879c30ea44f13b81057 | https://github.com/koehlma/pygrooveshark/blob/17673758ac12f54dc26ac879c30ea44f13b81057/src/grooveshark/__init__.py#L145-L164 |
41,317 | koehlma/pygrooveshark | src/grooveshark/__init__.py | Connection.header | def header(self, method, client='htmlshark'):
'''
generates Grooveshark API Json header
'''
return {'token': self._request_token(method, client),
'privacy': 0,
'uuid': self.session.user,
'clientRevision': grooveshark.const.CLIENTS[client]['... | python | def header(self, method, client='htmlshark'):
'''
generates Grooveshark API Json header
'''
return {'token': self._request_token(method, client),
'privacy': 0,
'uuid': self.session.user,
'clientRevision': grooveshark.const.CLIENTS[client]['... | [
"def",
"header",
"(",
"self",
",",
"method",
",",
"client",
"=",
"'htmlshark'",
")",
":",
"return",
"{",
"'token'",
":",
"self",
".",
"_request_token",
"(",
"method",
",",
"client",
")",
",",
"'privacy'",
":",
"0",
",",
"'uuid'",
":",
"self",
".",
"s... | generates Grooveshark API Json header | [
"generates",
"Grooveshark",
"API",
"Json",
"header"
] | 17673758ac12f54dc26ac879c30ea44f13b81057 | https://github.com/koehlma/pygrooveshark/blob/17673758ac12f54dc26ac879c30ea44f13b81057/src/grooveshark/__init__.py#L166-L176 |
41,318 | koehlma/pygrooveshark | src/grooveshark/__init__.py | Client.radio | def radio(self, radio):
'''
Get songs belong to a specific genre.
:param radio: genre to listen to
:rtype: a :class:`Radio` object
Genres:
This list is incomplete because there isn't an English translation for
some genres.
Please look at the sources for... | python | def radio(self, radio):
'''
Get songs belong to a specific genre.
:param radio: genre to listen to
:rtype: a :class:`Radio` object
Genres:
This list is incomplete because there isn't an English translation for
some genres.
Please look at the sources for... | [
"def",
"radio",
"(",
"self",
",",
"radio",
")",
":",
"artists",
"=",
"self",
".",
"connection",
".",
"request",
"(",
"'getArtistsForTagRadio'",
",",
"{",
"'tagID'",
":",
"radio",
"}",
",",
"self",
".",
"connection",
".",
"header",
"(",
"'getArtistsForTagRa... | Get songs belong to a specific genre.
:param radio: genre to listen to
:rtype: a :class:`Radio` object
Genres:
This list is incomplete because there isn't an English translation for
some genres.
Please look at the sources for all possible Tags.
+--------------... | [
"Get",
"songs",
"belong",
"to",
"a",
"specific",
"genre",
"."
] | 17673758ac12f54dc26ac879c30ea44f13b81057 | https://github.com/koehlma/pygrooveshark/blob/17673758ac12f54dc26ac879c30ea44f13b81057/src/grooveshark/__init__.py#L223-L284 |
41,319 | koehlma/pygrooveshark | src/grooveshark/__init__.py | Client.search | def search(self, query, type=SONGS):
'''
Search for songs, artists and albums.
:param query: search string
:param type: type to search for
:rtype: a generator generates :class:`Song`, :class:`Artist` and :class:`Album` objects
Search Types:
+-------------------... | python | def search(self, query, type=SONGS):
'''
Search for songs, artists and albums.
:param query: search string
:param type: type to search for
:rtype: a generator generates :class:`Song`, :class:`Artist` and :class:`Album` objects
Search Types:
+-------------------... | [
"def",
"search",
"(",
"self",
",",
"query",
",",
"type",
"=",
"SONGS",
")",
":",
"result",
"=",
"self",
".",
"connection",
".",
"request",
"(",
"'getResultsFromSearch'",
",",
"{",
"'query'",
":",
"query",
",",
"'type'",
":",
"type",
",",
"'guts'",
":",... | Search for songs, artists and albums.
:param query: search string
:param type: type to search for
:rtype: a generator generates :class:`Song`, :class:`Artist` and :class:`Album` objects
Search Types:
+---------------------------------+---------------------------------+
... | [
"Search",
"for",
"songs",
"artists",
"and",
"albums",
"."
] | 17673758ac12f54dc26ac879c30ea44f13b81057 | https://github.com/koehlma/pygrooveshark/blob/17673758ac12f54dc26ac879c30ea44f13b81057/src/grooveshark/__init__.py#L318-L353 |
41,320 | koehlma/pygrooveshark | src/grooveshark/__init__.py | Client.popular | def popular(self, period=DAILY):
'''
Get popular songs.
:param period: time period
:rtype: a generator generates :class:`Song` objects
Time periods:
+---------------------------------+-----------------------------------+
| Constant | Mean... | python | def popular(self, period=DAILY):
'''
Get popular songs.
:param period: time period
:rtype: a generator generates :class:`Song` objects
Time periods:
+---------------------------------+-----------------------------------+
| Constant | Mean... | [
"def",
"popular",
"(",
"self",
",",
"period",
"=",
"DAILY",
")",
":",
"songs",
"=",
"self",
".",
"connection",
".",
"request",
"(",
"'popularGetSongs'",
",",
"{",
"'type'",
":",
"period",
"}",
",",
"self",
".",
"connection",
".",
"header",
"(",
"'popul... | Get popular songs.
:param period: time period
:rtype: a generator generates :class:`Song` objects
Time periods:
+---------------------------------+-----------------------------------+
| Constant | Meaning |
+============... | [
"Get",
"popular",
"songs",
"."
] | 17673758ac12f54dc26ac879c30ea44f13b81057 | https://github.com/koehlma/pygrooveshark/blob/17673758ac12f54dc26ac879c30ea44f13b81057/src/grooveshark/__init__.py#L355-L376 |
41,321 | koehlma/pygrooveshark | src/grooveshark/__init__.py | Client.playlist | def playlist(self, playlist_id):
'''
Get a playlist from it's ID
:param playlist_id: ID of the playlist
:rtype: a :class:`Playlist` object
'''
playlist = self.connection.request(
'getPlaylistByID',
{'playlistID': playlist_id},
self.con... | python | def playlist(self, playlist_id):
'''
Get a playlist from it's ID
:param playlist_id: ID of the playlist
:rtype: a :class:`Playlist` object
'''
playlist = self.connection.request(
'getPlaylistByID',
{'playlistID': playlist_id},
self.con... | [
"def",
"playlist",
"(",
"self",
",",
"playlist_id",
")",
":",
"playlist",
"=",
"self",
".",
"connection",
".",
"request",
"(",
"'getPlaylistByID'",
",",
"{",
"'playlistID'",
":",
"playlist_id",
"}",
",",
"self",
".",
"connection",
".",
"header",
"(",
"'get... | Get a playlist from it's ID
:param playlist_id: ID of the playlist
:rtype: a :class:`Playlist` object | [
"Get",
"a",
"playlist",
"from",
"it",
"s",
"ID"
] | 17673758ac12f54dc26ac879c30ea44f13b81057 | https://github.com/koehlma/pygrooveshark/blob/17673758ac12f54dc26ac879c30ea44f13b81057/src/grooveshark/__init__.py#L378-L389 |
41,322 | koehlma/pygrooveshark | src/grooveshark/__init__.py | Client.collection | def collection(self, user_id):
"""
Get the song collection of a user.
:param user_id: ID of a user.
:rtype: list of :class:`Song`
"""
# TODO further evaluation of the page param, I don't know where the
# limit is.
dct = {'userID': user_id, 'page': 0}
... | python | def collection(self, user_id):
"""
Get the song collection of a user.
:param user_id: ID of a user.
:rtype: list of :class:`Song`
"""
# TODO further evaluation of the page param, I don't know where the
# limit is.
dct = {'userID': user_id, 'page': 0}
... | [
"def",
"collection",
"(",
"self",
",",
"user_id",
")",
":",
"# TODO further evaluation of the page param, I don't know where the",
"# limit is.",
"dct",
"=",
"{",
"'userID'",
":",
"user_id",
",",
"'page'",
":",
"0",
"}",
"r",
"=",
"'userGetSongsInLibrary'",
"result",
... | Get the song collection of a user.
:param user_id: ID of a user.
:rtype: list of :class:`Song` | [
"Get",
"the",
"song",
"collection",
"of",
"a",
"user",
"."
] | 17673758ac12f54dc26ac879c30ea44f13b81057 | https://github.com/koehlma/pygrooveshark/blob/17673758ac12f54dc26ac879c30ea44f13b81057/src/grooveshark/__init__.py#L391-L404 |
41,323 | ponty/confduino | confduino/hwpacklist.py | hwpack_names | def hwpack_names():
"""return installed hardware package names."""
ls = hwpack_dir().listdir()
ls = [x.name for x in ls]
ls = [x for x in ls if x != 'tools']
arduino_included = 'arduino' in ls
ls = [x for x in ls if x != 'arduino']
ls.sort()
if arduino_included:
ls = ['arduino'] ... | python | def hwpack_names():
"""return installed hardware package names."""
ls = hwpack_dir().listdir()
ls = [x.name for x in ls]
ls = [x for x in ls if x != 'tools']
arduino_included = 'arduino' in ls
ls = [x for x in ls if x != 'arduino']
ls.sort()
if arduino_included:
ls = ['arduino'] ... | [
"def",
"hwpack_names",
"(",
")",
":",
"ls",
"=",
"hwpack_dir",
"(",
")",
".",
"listdir",
"(",
")",
"ls",
"=",
"[",
"x",
".",
"name",
"for",
"x",
"in",
"ls",
"]",
"ls",
"=",
"[",
"x",
"for",
"x",
"in",
"ls",
"if",
"x",
"!=",
"'tools'",
"]",
... | return installed hardware package names. | [
"return",
"installed",
"hardware",
"package",
"names",
"."
] | f4c261e5e84997f145a8bdd001f471db74c9054b | https://github.com/ponty/confduino/blob/f4c261e5e84997f145a8bdd001f471db74c9054b/confduino/hwpacklist.py#L93-L103 |
41,324 | hatemile/hatemile-for-python | hatemile/util/css/tinycss/tinycssparser.py | TinyCSSParser._create_parser | def _create_parser(self, html_parser, current_url):
"""
Create the tinycss stylesheet.
:param html_parser: The HTML parser.
:type html_parser: hatemile.util.html.htmldomparser.HTMLDOMParser
:param current_url: The current URL of page.
:type current_url: str
"""
... | python | def _create_parser(self, html_parser, current_url):
"""
Create the tinycss stylesheet.
:param html_parser: The HTML parser.
:type html_parser: hatemile.util.html.htmldomparser.HTMLDOMParser
:param current_url: The current URL of page.
:type current_url: str
"""
... | [
"def",
"_create_parser",
"(",
"self",
",",
"html_parser",
",",
"current_url",
")",
":",
"css_code",
"=",
"''",
"elements",
"=",
"html_parser",
".",
"find",
"(",
"'style,link[rel=\"stylesheet\"]'",
")",
".",
"list_results",
"(",
")",
"for",
"element",
"in",
"el... | Create the tinycss stylesheet.
:param html_parser: The HTML parser.
:type html_parser: hatemile.util.html.htmldomparser.HTMLDOMParser
:param current_url: The current URL of page.
:type current_url: str | [
"Create",
"the",
"tinycss",
"stylesheet",
"."
] | 1e914f9aa09f6f8d78282af131311546ecba9fb8 | https://github.com/hatemile/hatemile-for-python/blob/1e914f9aa09f6f8d78282af131311546ecba9fb8/hatemile/util/css/tinycss/tinycssparser.py#L53-L76 |
41,325 | SeattleTestbed/seash | pyreadline/modes/notemacs.py | NotEmacsMode.readline | def readline(self, prompt=''):
u'''Try to act like GNU readline.'''
# handle startup_hook
if self.first_prompt:
self.first_prompt = False
if self.startup_hook:
try:
self.startup_hook()
except:
... | python | def readline(self, prompt=''):
u'''Try to act like GNU readline.'''
# handle startup_hook
if self.first_prompt:
self.first_prompt = False
if self.startup_hook:
try:
self.startup_hook()
except:
... | [
"def",
"readline",
"(",
"self",
",",
"prompt",
"=",
"''",
")",
":",
"# handle startup_hook\r",
"if",
"self",
".",
"first_prompt",
":",
"self",
".",
"first_prompt",
"=",
"False",
"if",
"self",
".",
"startup_hook",
":",
"try",
":",
"self",
".",
"startup_hook... | u'''Try to act like GNU readline. | [
"u",
"Try",
"to",
"act",
"like",
"GNU",
"readline",
"."
] | 40f9d2285662ff8b61e0468b4196acee089b273b | https://github.com/SeattleTestbed/seash/blob/40f9d2285662ff8b61e0468b4196acee089b273b/pyreadline/modes/notemacs.py#L51-L89 |
41,326 | SeattleTestbed/seash | pyreadline/modes/notemacs.py | NotEmacsMode.history_search_backward | def history_search_backward(self, e): # ()
u'''Search backward through the history for the string of characters
between the start of the current line and the point. This is a
non-incremental search. By default, this command is unbound.'''
self.l_buffer=self._history.history_search_ba... | python | def history_search_backward(self, e): # ()
u'''Search backward through the history for the string of characters
between the start of the current line and the point. This is a
non-incremental search. By default, this command is unbound.'''
self.l_buffer=self._history.history_search_ba... | [
"def",
"history_search_backward",
"(",
"self",
",",
"e",
")",
":",
"# ()\r",
"self",
".",
"l_buffer",
"=",
"self",
".",
"_history",
".",
"history_search_backward",
"(",
"self",
".",
"l_buffer",
")"
] | u'''Search backward through the history for the string of characters
between the start of the current line and the point. This is a
non-incremental search. By default, this command is unbound. | [
"u",
"Search",
"backward",
"through",
"the",
"history",
"for",
"the",
"string",
"of",
"characters",
"between",
"the",
"start",
"of",
"the",
"current",
"line",
"and",
"the",
"point",
".",
"This",
"is",
"a",
"non",
"-",
"incremental",
"search",
".",
"By",
... | 40f9d2285662ff8b61e0468b4196acee089b273b | https://github.com/SeattleTestbed/seash/blob/40f9d2285662ff8b61e0468b4196acee089b273b/pyreadline/modes/notemacs.py#L229-L233 |
41,327 | SeattleTestbed/seash | pyreadline/modes/notemacs.py | NotEmacsMode.quoted_insert | def quoted_insert(self, e): # (C-q or C-v)
u'''Add the next character typed to the line verbatim. This is how to
insert key sequences like C-q, for example.'''
e = self.console.getkeypress()
self.insert_text(e.char) | python | def quoted_insert(self, e): # (C-q or C-v)
u'''Add the next character typed to the line verbatim. This is how to
insert key sequences like C-q, for example.'''
e = self.console.getkeypress()
self.insert_text(e.char) | [
"def",
"quoted_insert",
"(",
"self",
",",
"e",
")",
":",
"# (C-q or C-v)\r",
"e",
"=",
"self",
".",
"console",
".",
"getkeypress",
"(",
")",
"self",
".",
"insert_text",
"(",
"e",
".",
"char",
")"
] | u'''Add the next character typed to the line verbatim. This is how to
insert key sequences like C-q, for example. | [
"u",
"Add",
"the",
"next",
"character",
"typed",
"to",
"the",
"line",
"verbatim",
".",
"This",
"is",
"how",
"to",
"insert",
"key",
"sequences",
"like",
"C",
"-",
"q",
"for",
"example",
"."
] | 40f9d2285662ff8b61e0468b4196acee089b273b | https://github.com/SeattleTestbed/seash/blob/40f9d2285662ff8b61e0468b4196acee089b273b/pyreadline/modes/notemacs.py#L267-L271 |
41,328 | SeattleTestbed/seash | pyreadline/modes/notemacs.py | NotEmacsMode.ipython_paste | def ipython_paste(self,e):
u'''Paste windows clipboard. If enable_ipython_paste_list_of_lists is
True then try to convert tabseparated data to repr of list of lists or
repr of array'''
if self.enable_win32_clipboard:
txt=clipboard.get_clipboard_text_and_convert(
... | python | def ipython_paste(self,e):
u'''Paste windows clipboard. If enable_ipython_paste_list_of_lists is
True then try to convert tabseparated data to repr of list of lists or
repr of array'''
if self.enable_win32_clipboard:
txt=clipboard.get_clipboard_text_and_convert(
... | [
"def",
"ipython_paste",
"(",
"self",
",",
"e",
")",
":",
"if",
"self",
".",
"enable_win32_clipboard",
":",
"txt",
"=",
"clipboard",
".",
"get_clipboard_text_and_convert",
"(",
"self",
".",
"enable_ipython_paste_list_of_lists",
")",
"if",
"self",
".",
"enable_ipyth... | u'''Paste windows clipboard. If enable_ipython_paste_list_of_lists is
True then try to convert tabseparated data to repr of list of lists or
repr of array | [
"u",
"Paste",
"windows",
"clipboard",
".",
"If",
"enable_ipython_paste_list_of_lists",
"is",
"True",
"then",
"try",
"to",
"convert",
"tabseparated",
"data",
"to",
"repr",
"of",
"list",
"of",
"lists",
"or",
"repr",
"of",
"array"
] | 40f9d2285662ff8b61e0468b4196acee089b273b | https://github.com/SeattleTestbed/seash/blob/40f9d2285662ff8b61e0468b4196acee089b273b/pyreadline/modes/notemacs.py#L416-L426 |
41,329 | corydodt/Codado | codado/tx.py | Main.main | def main(cls, args=None):
"""
Fill in command-line arguments from argv
"""
if args is None:
args = sys.argv[1:]
try:
o = cls()
o.parseOptions(args)
except usage.UsageError as e:
print(o.getSynopsis())
print(o.ge... | python | def main(cls, args=None):
"""
Fill in command-line arguments from argv
"""
if args is None:
args = sys.argv[1:]
try:
o = cls()
o.parseOptions(args)
except usage.UsageError as e:
print(o.getSynopsis())
print(o.ge... | [
"def",
"main",
"(",
"cls",
",",
"args",
"=",
"None",
")",
":",
"if",
"args",
"is",
"None",
":",
"args",
"=",
"sys",
".",
"argv",
"[",
"1",
":",
"]",
"try",
":",
"o",
"=",
"cls",
"(",
")",
"o",
".",
"parseOptions",
"(",
"args",
")",
"except",
... | Fill in command-line arguments from argv | [
"Fill",
"in",
"command",
"-",
"line",
"arguments",
"from",
"argv"
] | 487d51ec6132c05aa88e2f128012c95ccbf6928e | https://github.com/corydodt/Codado/blob/487d51ec6132c05aa88e2f128012c95ccbf6928e/codado/tx.py#L38-L57 |
41,330 | RI-imaging/qpformat | qpformat/file_formats/series_zip_tif_phasics.py | SeriesZipTifPhasics._index_files | def _index_files(path):
"""Search zip file for SID PHA files"""
with zipfile.ZipFile(path) as zf:
names = sorted(zf.namelist())
names = [nn for nn in names if nn.endswith(".tif")]
names = [nn for nn in names if nn.startswith("SID PHA")]
phasefiles = []
... | python | def _index_files(path):
"""Search zip file for SID PHA files"""
with zipfile.ZipFile(path) as zf:
names = sorted(zf.namelist())
names = [nn for nn in names if nn.endswith(".tif")]
names = [nn for nn in names if nn.startswith("SID PHA")]
phasefiles = []
... | [
"def",
"_index_files",
"(",
"path",
")",
":",
"with",
"zipfile",
".",
"ZipFile",
"(",
"path",
")",
"as",
"zf",
":",
"names",
"=",
"sorted",
"(",
"zf",
".",
"namelist",
"(",
")",
")",
"names",
"=",
"[",
"nn",
"for",
"nn",
"in",
"names",
"if",
"nn"... | Search zip file for SID PHA files | [
"Search",
"zip",
"file",
"for",
"SID",
"PHA",
"files"
] | 364e29d7d9e8b9f1d7a4a25c753d1baf9d73d5eb | https://github.com/RI-imaging/qpformat/blob/364e29d7d9e8b9f1d7a4a25c753d1baf9d73d5eb/qpformat/file_formats/series_zip_tif_phasics.py#L40-L52 |
41,331 | RI-imaging/qpformat | qpformat/file_formats/series_zip_tif_phasics.py | SeriesZipTifPhasics.files | def files(self):
"""List of Phasics tif file names in the input zip file"""
if self._files is None:
self._files = SeriesZipTifPhasics._index_files(self.path)
return self._files | python | def files(self):
"""List of Phasics tif file names in the input zip file"""
if self._files is None:
self._files = SeriesZipTifPhasics._index_files(self.path)
return self._files | [
"def",
"files",
"(",
"self",
")",
":",
"if",
"self",
".",
"_files",
"is",
"None",
":",
"self",
".",
"_files",
"=",
"SeriesZipTifPhasics",
".",
"_index_files",
"(",
"self",
".",
"path",
")",
"return",
"self",
".",
"_files"
] | List of Phasics tif file names in the input zip file | [
"List",
"of",
"Phasics",
"tif",
"file",
"names",
"in",
"the",
"input",
"zip",
"file"
] | 364e29d7d9e8b9f1d7a4a25c753d1baf9d73d5eb | https://github.com/RI-imaging/qpformat/blob/364e29d7d9e8b9f1d7a4a25c753d1baf9d73d5eb/qpformat/file_formats/series_zip_tif_phasics.py#L55-L59 |
41,332 | RI-imaging/qpformat | qpformat/file_formats/series_zip_tif_phasics.py | SeriesZipTifPhasics.verify | def verify(path):
"""Verify that `path` is a zip file with Phasics TIFF files"""
valid = False
try:
zf = zipfile.ZipFile(path)
except (zipfile.BadZipfile, IsADirectoryError):
pass
else:
names = sorted(zf.namelist())
names = [nn for ... | python | def verify(path):
"""Verify that `path` is a zip file with Phasics TIFF files"""
valid = False
try:
zf = zipfile.ZipFile(path)
except (zipfile.BadZipfile, IsADirectoryError):
pass
else:
names = sorted(zf.namelist())
names = [nn for ... | [
"def",
"verify",
"(",
"path",
")",
":",
"valid",
"=",
"False",
"try",
":",
"zf",
"=",
"zipfile",
".",
"ZipFile",
"(",
"path",
")",
"except",
"(",
"zipfile",
".",
"BadZipfile",
",",
"IsADirectoryError",
")",
":",
"pass",
"else",
":",
"names",
"=",
"so... | Verify that `path` is a zip file with Phasics TIFF files | [
"Verify",
"that",
"path",
"is",
"a",
"zip",
"file",
"with",
"Phasics",
"TIFF",
"files"
] | 364e29d7d9e8b9f1d7a4a25c753d1baf9d73d5eb | https://github.com/RI-imaging/qpformat/blob/364e29d7d9e8b9f1d7a4a25c753d1baf9d73d5eb/qpformat/file_formats/series_zip_tif_phasics.py#L74-L92 |
41,333 | metagriffin/asset | asset/resource.py | chunks | def chunks(stream, size=None):
'''
Returns a generator of chunks from the `stream` with a maximum
size of `size`. I don't know why this isn't part of core Python.
:Parameters:
stream : file-like object
The stream to fetch the chunks from. Note that the stream will
not be repositioned in any way.
... | python | def chunks(stream, size=None):
'''
Returns a generator of chunks from the `stream` with a maximum
size of `size`. I don't know why this isn't part of core Python.
:Parameters:
stream : file-like object
The stream to fetch the chunks from. Note that the stream will
not be repositioned in any way.
... | [
"def",
"chunks",
"(",
"stream",
",",
"size",
"=",
"None",
")",
":",
"if",
"size",
"==",
"'lines'",
":",
"for",
"item",
"in",
"stream",
":",
"# for item in stream.readline():",
"yield",
"item",
"return",
"if",
"size",
"is",
"None",
":",
"size",
"=",
"MAXB... | Returns a generator of chunks from the `stream` with a maximum
size of `size`. I don't know why this isn't part of core Python.
:Parameters:
stream : file-like object
The stream to fetch the chunks from. Note that the stream will
not be repositioned in any way.
size : int | 'lines'; default: null
... | [
"Returns",
"a",
"generator",
"of",
"chunks",
"from",
"the",
"stream",
"with",
"a",
"maximum",
"size",
"of",
"size",
".",
"I",
"don",
"t",
"know",
"why",
"this",
"isn",
"t",
"part",
"of",
"core",
"Python",
"."
] | f2c5e599cd4688f82216d4b5cfa87aab96d8bb8c | https://github.com/metagriffin/asset/blob/f2c5e599cd4688f82216d4b5cfa87aab96d8bb8c/asset/resource.py#L279-L309 |
41,334 | contains-io/rcli | rcli/log.py | write_logfile | def write_logfile():
# type: () -> None
"""Write a DEBUG log file COMMAND-YYYYMMDD-HHMMSS.ffffff.log."""
command = os.path.basename(os.path.realpath(os.path.abspath(sys.argv[0])))
now = datetime.datetime.now().strftime('%Y%m%d-%H%M%S.%f')
filename = '{}-{}.log'.format(command, now)
with open(fil... | python | def write_logfile():
# type: () -> None
"""Write a DEBUG log file COMMAND-YYYYMMDD-HHMMSS.ffffff.log."""
command = os.path.basename(os.path.realpath(os.path.abspath(sys.argv[0])))
now = datetime.datetime.now().strftime('%Y%m%d-%H%M%S.%f')
filename = '{}-{}.log'.format(command, now)
with open(fil... | [
"def",
"write_logfile",
"(",
")",
":",
"# type: () -> None",
"command",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"os",
".",
"path",
".",
"realpath",
"(",
"os",
".",
"path",
".",
"abspath",
"(",
"sys",
".",
"argv",
"[",
"0",
"]",
")",
")",
")",... | Write a DEBUG log file COMMAND-YYYYMMDD-HHMMSS.ffffff.log. | [
"Write",
"a",
"DEBUG",
"log",
"file",
"COMMAND",
"-",
"YYYYMMDD",
"-",
"HHMMSS",
".",
"ffffff",
".",
"log",
"."
] | cdd6191a0e0a19bc767f84921650835d099349cf | https://github.com/contains-io/rcli/blob/cdd6191a0e0a19bc767f84921650835d099349cf/rcli/log.py#L35-L46 |
41,335 | contains-io/rcli | rcli/log.py | excepthook | def excepthook(type, value, traceback): # pylint: disable=unused-argument
"""Log exceptions instead of printing a traceback to stderr."""
try:
six.reraise(type, value, traceback)
except type:
_LOGGER.exception(str(value))
if isinstance(value, KeyboardInterrupt):
message = "Cance... | python | def excepthook(type, value, traceback): # pylint: disable=unused-argument
"""Log exceptions instead of printing a traceback to stderr."""
try:
six.reraise(type, value, traceback)
except type:
_LOGGER.exception(str(value))
if isinstance(value, KeyboardInterrupt):
message = "Cance... | [
"def",
"excepthook",
"(",
"type",
",",
"value",
",",
"traceback",
")",
":",
"# pylint: disable=unused-argument",
"try",
":",
"six",
".",
"reraise",
"(",
"type",
",",
"value",
",",
"traceback",
")",
"except",
"type",
":",
"_LOGGER",
".",
"exception",
"(",
"... | Log exceptions instead of printing a traceback to stderr. | [
"Log",
"exceptions",
"instead",
"of",
"printing",
"a",
"traceback",
"to",
"stderr",
"."
] | cdd6191a0e0a19bc767f84921650835d099349cf | https://github.com/contains-io/rcli/blob/cdd6191a0e0a19bc767f84921650835d099349cf/rcli/log.py#L56-L66 |
41,336 | contains-io/rcli | rcli/log.py | handle_unexpected_exception | def handle_unexpected_exception(exc):
# type: (BaseException) -> str
"""Return an error message and write a log file if logging was not enabled.
Args:
exc: The unexpected exception.
Returns:
A message to display to the user concerning the unexpected exception.
"""
try:
... | python | def handle_unexpected_exception(exc):
# type: (BaseException) -> str
"""Return an error message and write a log file if logging was not enabled.
Args:
exc: The unexpected exception.
Returns:
A message to display to the user concerning the unexpected exception.
"""
try:
... | [
"def",
"handle_unexpected_exception",
"(",
"exc",
")",
":",
"# type: (BaseException) -> str",
"try",
":",
"write_logfile",
"(",
")",
"addendum",
"=",
"'Please see the log file for more information.'",
"except",
"IOError",
":",
"addendum",
"=",
"'Unable to write log file.'",
... | Return an error message and write a log file if logging was not enabled.
Args:
exc: The unexpected exception.
Returns:
A message to display to the user concerning the unexpected exception. | [
"Return",
"an",
"error",
"message",
"and",
"write",
"a",
"log",
"file",
"if",
"logging",
"was",
"not",
"enabled",
"."
] | cdd6191a0e0a19bc767f84921650835d099349cf | https://github.com/contains-io/rcli/blob/cdd6191a0e0a19bc767f84921650835d099349cf/rcli/log.py#L70-L89 |
41,337 | contains-io/rcli | rcli/log.py | enable_logging | def enable_logging(log_level):
# type: (typing.Union[None, int]) -> None
"""Configure the root logger and a logfile handler.
Args:
log_level: The logging level to set the logger handler.
"""
root_logger = logging.getLogger()
root_logger.setLevel(logging.DEBUG)
logfile_handler = logg... | python | def enable_logging(log_level):
# type: (typing.Union[None, int]) -> None
"""Configure the root logger and a logfile handler.
Args:
log_level: The logging level to set the logger handler.
"""
root_logger = logging.getLogger()
root_logger.setLevel(logging.DEBUG)
logfile_handler = logg... | [
"def",
"enable_logging",
"(",
"log_level",
")",
":",
"# type: (typing.Union[None, int]) -> None",
"root_logger",
"=",
"logging",
".",
"getLogger",
"(",
")",
"root_logger",
".",
"setLevel",
"(",
"logging",
".",
"DEBUG",
")",
"logfile_handler",
"=",
"logging",
".",
... | Configure the root logger and a logfile handler.
Args:
log_level: The logging level to set the logger handler. | [
"Configure",
"the",
"root",
"logger",
"and",
"a",
"logfile",
"handler",
"."
] | cdd6191a0e0a19bc767f84921650835d099349cf | https://github.com/contains-io/rcli/blob/cdd6191a0e0a19bc767f84921650835d099349cf/rcli/log.py#L92-L112 |
41,338 | contains-io/rcli | rcli/log.py | get_log_level | def get_log_level(args):
# type: (typing.Dict[str, typing.Any]) -> int
"""Get the log level from the CLI arguments.
Removes logging arguments from sys.argv.
Args:
args: The parsed docopt arguments to be used to determine the logging
level.
Returns:
The correct log leve... | python | def get_log_level(args):
# type: (typing.Dict[str, typing.Any]) -> int
"""Get the log level from the CLI arguments.
Removes logging arguments from sys.argv.
Args:
args: The parsed docopt arguments to be used to determine the logging
level.
Returns:
The correct log leve... | [
"def",
"get_log_level",
"(",
"args",
")",
":",
"# type: (typing.Dict[str, typing.Any]) -> int",
"index",
"=",
"-",
"1",
"log_level",
"=",
"None",
"if",
"'<command>'",
"in",
"args",
"and",
"args",
"[",
"'<command>'",
"]",
":",
"index",
"=",
"sys",
".",
"argv",
... | Get the log level from the CLI arguments.
Removes logging arguments from sys.argv.
Args:
args: The parsed docopt arguments to be used to determine the logging
level.
Returns:
The correct log level based on the three CLI arguments given.
Raises:
ValueError: Raised ... | [
"Get",
"the",
"log",
"level",
"from",
"the",
"CLI",
"arguments",
"."
] | cdd6191a0e0a19bc767f84921650835d099349cf | https://github.com/contains-io/rcli/blob/cdd6191a0e0a19bc767f84921650835d099349cf/rcli/log.py#L115-L154 |
41,339 | contains-io/rcli | rcli/log.py | _logfile_sigterm_handler | def _logfile_sigterm_handler(*_):
# type: (...) -> None
"""Handle exit signals and write out a log file.
Raises:
SystemExit: Contains the signal as the return code.
"""
logging.error('Received SIGTERM.')
write_logfile()
print('Received signal. Please see the log file for more inform... | python | def _logfile_sigterm_handler(*_):
# type: (...) -> None
"""Handle exit signals and write out a log file.
Raises:
SystemExit: Contains the signal as the return code.
"""
logging.error('Received SIGTERM.')
write_logfile()
print('Received signal. Please see the log file for more inform... | [
"def",
"_logfile_sigterm_handler",
"(",
"*",
"_",
")",
":",
"# type: (...) -> None",
"logging",
".",
"error",
"(",
"'Received SIGTERM.'",
")",
"write_logfile",
"(",
")",
"print",
"(",
"'Received signal. Please see the log file for more information.'",
",",
"file",
"=",
... | Handle exit signals and write out a log file.
Raises:
SystemExit: Contains the signal as the return code. | [
"Handle",
"exit",
"signals",
"and",
"write",
"out",
"a",
"log",
"file",
"."
] | cdd6191a0e0a19bc767f84921650835d099349cf | https://github.com/contains-io/rcli/blob/cdd6191a0e0a19bc767f84921650835d099349cf/rcli/log.py#L157-L168 |
41,340 | contains-io/rcli | rcli/log.py | _LogColorFormatter.format | def format(self, record):
# type: (logging.LogRecord) -> str
"""Format the log record with timestamps and level based colors.
Args:
record: The log record to format.
Returns:
The formatted log record.
"""
if record.levelno >= logging.ERROR:
... | python | def format(self, record):
# type: (logging.LogRecord) -> str
"""Format the log record with timestamps and level based colors.
Args:
record: The log record to format.
Returns:
The formatted log record.
"""
if record.levelno >= logging.ERROR:
... | [
"def",
"format",
"(",
"self",
",",
"record",
")",
":",
"# type: (logging.LogRecord) -> str",
"if",
"record",
".",
"levelno",
">=",
"logging",
".",
"ERROR",
":",
"color",
"=",
"colorama",
".",
"Fore",
".",
"RED",
"elif",
"record",
".",
"levelno",
">=",
"log... | Format the log record with timestamps and level based colors.
Args:
record: The log record to format.
Returns:
The formatted log record. | [
"Format",
"the",
"log",
"record",
"with",
"timestamps",
"and",
"level",
"based",
"colors",
"."
] | cdd6191a0e0a19bc767f84921650835d099349cf | https://github.com/contains-io/rcli/blob/cdd6191a0e0a19bc767f84921650835d099349cf/rcli/log.py#L174-L205 |
41,341 | sherlocke/pywatson | pywatson/watson.py | Watson.ask_question | def ask_question(self, question_text, question=None):
"""Ask Watson a question via the Question and Answer API
:param question_text: question to ask Watson
:type question_text: str
:param question: if question_text is not provided, a Question object
representing... | python | def ask_question(self, question_text, question=None):
"""Ask Watson a question via the Question and Answer API
:param question_text: question to ask Watson
:type question_text: str
:param question: if question_text is not provided, a Question object
representing... | [
"def",
"ask_question",
"(",
"self",
",",
"question_text",
",",
"question",
"=",
"None",
")",
":",
"if",
"question",
"is",
"not",
"None",
":",
"q",
"=",
"question",
".",
"to_dict",
"(",
")",
"else",
":",
"q",
"=",
"WatsonQuestion",
"(",
"question_text",
... | Ask Watson a question via the Question and Answer API
:param question_text: question to ask Watson
:type question_text: str
:param question: if question_text is not provided, a Question object
representing the question to ask Watson
:type question: WatsonQuestio... | [
"Ask",
"Watson",
"a",
"question",
"via",
"the",
"Question",
"and",
"Answer",
"API"
] | ab15d1ca3c01a185136b420d443f712dfa865485 | https://github.com/sherlocke/pywatson/blob/ab15d1ca3c01a185136b420d443f712dfa865485/pywatson/watson.py#L14-L36 |
41,342 | erikvw/django-collect-offline-files | django_collect_offline_files/file_queues/process_queue.py | process_queue | def process_queue(queue=None, **kwargs):
"""Loops and waits on queue calling queue's `next_task` method.
If an exception occurs, log the error, log the exception,
and break.
"""
while True:
item = queue.get()
if item is None:
queue.task_done()
logger.info(f"{... | python | def process_queue(queue=None, **kwargs):
"""Loops and waits on queue calling queue's `next_task` method.
If an exception occurs, log the error, log the exception,
and break.
"""
while True:
item = queue.get()
if item is None:
queue.task_done()
logger.info(f"{... | [
"def",
"process_queue",
"(",
"queue",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"while",
"True",
":",
"item",
"=",
"queue",
".",
"get",
"(",
")",
"if",
"item",
"is",
"None",
":",
"queue",
".",
"task_done",
"(",
")",
"logger",
".",
"info",
"... | Loops and waits on queue calling queue's `next_task` method.
If an exception occurs, log the error, log the exception,
and break. | [
"Loops",
"and",
"waits",
"on",
"queue",
"calling",
"queue",
"s",
"next_task",
"method",
"."
] | 78f61c823ea3926eb88206b019b5dca3c36017da | https://github.com/erikvw/django-collect-offline-files/blob/78f61c823ea3926eb88206b019b5dca3c36017da/django_collect_offline_files/file_queues/process_queue.py#L11-L39 |
41,343 | CMUSTRUDEL/strudel.utils | stutils/decorators.py | memoize | def memoize(func):
""" Classic memoize decorator for non-class methods """
cache = {}
@functools.wraps(func)
def wrapper(*args):
key = "__".join(str(arg) for arg in args)
if key not in cache:
cache[key] = func(*args)
return cache[key]
return wrapper | python | def memoize(func):
""" Classic memoize decorator for non-class methods """
cache = {}
@functools.wraps(func)
def wrapper(*args):
key = "__".join(str(arg) for arg in args)
if key not in cache:
cache[key] = func(*args)
return cache[key]
return wrapper | [
"def",
"memoize",
"(",
"func",
")",
":",
"cache",
"=",
"{",
"}",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"wrapper",
"(",
"*",
"args",
")",
":",
"key",
"=",
"\"__\"",
".",
"join",
"(",
"str",
"(",
"arg",
")",
"for",
"arg",
"in",... | Classic memoize decorator for non-class methods | [
"Classic",
"memoize",
"decorator",
"for",
"non",
"-",
"class",
"methods"
] | 888ef72fcdb851b5873092bc9c4d6958733691f2 | https://github.com/CMUSTRUDEL/strudel.utils/blob/888ef72fcdb851b5873092bc9c4d6958733691f2/stutils/decorators.py#L156-L166 |
41,344 | CMUSTRUDEL/strudel.utils | stutils/decorators.py | cached_method | def cached_method(func):
""" Memoize for class methods """
@functools.wraps(func)
def wrapper(self, *args):
if not hasattr(self, "_cache"):
self._cache = {}
key = _argstring((func.__name__,) + args)
if key not in self._cache:
self._cache[key] = func(self, *arg... | python | def cached_method(func):
""" Memoize for class methods """
@functools.wraps(func)
def wrapper(self, *args):
if not hasattr(self, "_cache"):
self._cache = {}
key = _argstring((func.__name__,) + args)
if key not in self._cache:
self._cache[key] = func(self, *arg... | [
"def",
"cached_method",
"(",
"func",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"wrapper",
"(",
"self",
",",
"*",
"args",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"\"_cache\"",
")",
":",
"self",
".",
"_cache",
"="... | Memoize for class methods | [
"Memoize",
"for",
"class",
"methods"
] | 888ef72fcdb851b5873092bc9c4d6958733691f2 | https://github.com/CMUSTRUDEL/strudel.utils/blob/888ef72fcdb851b5873092bc9c4d6958733691f2/stutils/decorators.py#L169-L179 |
41,345 | CMUSTRUDEL/strudel.utils | stutils/decorators.py | guard | def guard(func):
""" Prevents the decorated function from parallel execution.
Internally, this decorator creates a Lock object and transparently
obtains/releases it when calling the function.
"""
semaphore = threading.Lock()
@functools.wraps(func)
def wrapper(*args, **kwargs):
s... | python | def guard(func):
""" Prevents the decorated function from parallel execution.
Internally, this decorator creates a Lock object and transparently
obtains/releases it when calling the function.
"""
semaphore = threading.Lock()
@functools.wraps(func)
def wrapper(*args, **kwargs):
s... | [
"def",
"guard",
"(",
"func",
")",
":",
"semaphore",
"=",
"threading",
".",
"Lock",
"(",
")",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"semaphore",
".",
"acquire",
"(",
... | Prevents the decorated function from parallel execution.
Internally, this decorator creates a Lock object and transparently
obtains/releases it when calling the function. | [
"Prevents",
"the",
"decorated",
"function",
"from",
"parallel",
"execution",
"."
] | 888ef72fcdb851b5873092bc9c4d6958733691f2 | https://github.com/CMUSTRUDEL/strudel.utils/blob/888ef72fcdb851b5873092bc9c4d6958733691f2/stutils/decorators.py#L241-L257 |
41,346 | CMUSTRUDEL/strudel.utils | stutils/decorators.py | threadpool | def threadpool(num_workers=None):
"""Apply stutils.mapreduce.map to the given function"""
def decorator(func):
@functools.wraps(func)
def wrapper(data):
return mapreduce.map(func, data, num_workers)
return wrapper
return decorator | python | def threadpool(num_workers=None):
"""Apply stutils.mapreduce.map to the given function"""
def decorator(func):
@functools.wraps(func)
def wrapper(data):
return mapreduce.map(func, data, num_workers)
return wrapper
return decorator | [
"def",
"threadpool",
"(",
"num_workers",
"=",
"None",
")",
":",
"def",
"decorator",
"(",
"func",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"wrapper",
"(",
"data",
")",
":",
"return",
"mapreduce",
".",
"map",
"(",
"func",
",",... | Apply stutils.mapreduce.map to the given function | [
"Apply",
"stutils",
".",
"mapreduce",
".",
"map",
"to",
"the",
"given",
"function"
] | 888ef72fcdb851b5873092bc9c4d6958733691f2 | https://github.com/CMUSTRUDEL/strudel.utils/blob/888ef72fcdb851b5873092bc9c4d6958733691f2/stutils/decorators.py#L260-L267 |
41,347 | CMUSTRUDEL/strudel.utils | stutils/decorators.py | _FSCacher.invalidate_all | def invalidate_all(self):
""" Remove all files caching this function """
for fname in os.listdir(self.cache_path):
if fname.startswith(self.func.__name__ + "."):
os.remove(os.path.join(self.cache_path, fname)) | python | def invalidate_all(self):
""" Remove all files caching this function """
for fname in os.listdir(self.cache_path):
if fname.startswith(self.func.__name__ + "."):
os.remove(os.path.join(self.cache_path, fname)) | [
"def",
"invalidate_all",
"(",
"self",
")",
":",
"for",
"fname",
"in",
"os",
".",
"listdir",
"(",
"self",
".",
"cache_path",
")",
":",
"if",
"fname",
".",
"startswith",
"(",
"self",
".",
"func",
".",
"__name__",
"+",
"\".\"",
")",
":",
"os",
".",
"r... | Remove all files caching this function | [
"Remove",
"all",
"files",
"caching",
"this",
"function"
] | 888ef72fcdb851b5873092bc9c4d6958733691f2 | https://github.com/CMUSTRUDEL/strudel.utils/blob/888ef72fcdb851b5873092bc9c4d6958733691f2/stutils/decorators.py#L106-L110 |
41,348 | kmedian/ctmc | ctmc/ctmc_func.py | ctmc | def ctmc(data, numstates, transintv=1.0, toltime=1e-8, debug=False):
""" Continous Time Markov Chain
Parameters
----------
data : list of lists
A python list of N examples (e.g. rating histories of N companies,
the event data of N basketball games, etc.). The i-th example
consis... | python | def ctmc(data, numstates, transintv=1.0, toltime=1e-8, debug=False):
""" Continous Time Markov Chain
Parameters
----------
data : list of lists
A python list of N examples (e.g. rating histories of N companies,
the event data of N basketball games, etc.). The i-th example
consis... | [
"def",
"ctmc",
"(",
"data",
",",
"numstates",
",",
"transintv",
"=",
"1.0",
",",
"toltime",
"=",
"1e-8",
",",
"debug",
"=",
"False",
")",
":",
"# raise an exception if the data format is wrong",
"if",
"debug",
":",
"datacheck",
"(",
"data",
",",
"numstates",
... | Continous Time Markov Chain
Parameters
----------
data : list of lists
A python list of N examples (e.g. rating histories of N companies,
the event data of N basketball games, etc.). The i-th example
consist of one list with M_i encoded state labels and M_i the
durations or ... | [
"Continous",
"Time",
"Markov",
"Chain"
] | e30747f797ce777fd2aaa1b7ee5a77e91d7db5e4 | https://github.com/kmedian/ctmc/blob/e30747f797ce777fd2aaa1b7ee5a77e91d7db5e4/ctmc/ctmc_func.py#L9-L106 |
41,349 | metagriffin/asset | asset/plugin.py | plugins | def plugins(group, spec=None):
# TODO: share this documentation with `../doc/plugin.rst`...
'''
Returns a `PluginSet` object for the specified setuptools-style
entrypoint `group`. This is just a wrapper around
`pkg_resources.iter_entry_points` that allows the plugins to sort
and override themselves.
The ... | python | def plugins(group, spec=None):
# TODO: share this documentation with `../doc/plugin.rst`...
'''
Returns a `PluginSet` object for the specified setuptools-style
entrypoint `group`. This is just a wrapper around
`pkg_resources.iter_entry_points` that allows the plugins to sort
and override themselves.
The ... | [
"def",
"plugins",
"(",
"group",
",",
"spec",
"=",
"None",
")",
":",
"# TODO: share this documentation with `../doc/plugin.rst`...",
"pspec",
"=",
"_parse_spec",
"(",
"spec",
")",
"plugs",
"=",
"list",
"(",
"_get_registered_plugins",
"(",
"group",
",",
"pspec",
")"... | Returns a `PluginSet` object for the specified setuptools-style
entrypoint `group`. This is just a wrapper around
`pkg_resources.iter_entry_points` that allows the plugins to sort
and override themselves.
The optional `spec` parameter controls how and what plugins are
loaded. If it is ``None`` or the special... | [
"Returns",
"a",
"PluginSet",
"object",
"for",
"the",
"specified",
"setuptools",
"-",
"style",
"entrypoint",
"group",
".",
"This",
"is",
"just",
"a",
"wrapper",
"around",
"pkg_resources",
".",
"iter_entry_points",
"that",
"allows",
"the",
"plugins",
"to",
"sort",... | f2c5e599cd4688f82216d4b5cfa87aab96d8bb8c | https://github.com/metagriffin/asset/blob/f2c5e599cd4688f82216d4b5cfa87aab96d8bb8c/asset/plugin.py#L112-L184 |
41,350 | metagriffin/asset | asset/plugin.py | PluginSet.handle | def handle(self, object, *args, **kw):
'''
Calls each plugin in this PluginSet with the specified object,
arguments, and keywords in the standard group plugin order. The
return value from each successive invoked plugin is passed as the
first parameter to the next plugin. The final return value is th... | python | def handle(self, object, *args, **kw):
'''
Calls each plugin in this PluginSet with the specified object,
arguments, and keywords in the standard group plugin order. The
return value from each successive invoked plugin is passed as the
first parameter to the next plugin. The final return value is th... | [
"def",
"handle",
"(",
"self",
",",
"object",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"if",
"not",
"bool",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"spec",
"or",
"self",
".",
"spec",
"==",
"SPEC_ALL",
":",
"raise",
"ValueError",
... | Calls each plugin in this PluginSet with the specified object,
arguments, and keywords in the standard group plugin order. The
return value from each successive invoked plugin is passed as the
first parameter to the next plugin. The final return value is the
object returned from the last plugin.
If... | [
"Calls",
"each",
"plugin",
"in",
"this",
"PluginSet",
"with",
"the",
"specified",
"object",
"arguments",
"and",
"keywords",
"in",
"the",
"standard",
"group",
"plugin",
"order",
".",
"The",
"return",
"value",
"from",
"each",
"successive",
"invoked",
"plugin",
"... | f2c5e599cd4688f82216d4b5cfa87aab96d8bb8c | https://github.com/metagriffin/asset/blob/f2c5e599cd4688f82216d4b5cfa87aab96d8bb8c/asset/plugin.py#L50-L68 |
41,351 | metagriffin/asset | asset/plugin.py | PluginSet.select | def select(self, name):
'''
Returns a new PluginSet that has only the plugins in this that are
named `name`.
'''
return PluginSet(self.group, name, [
plug for plug in self.plugins if plug.name == name]) | python | def select(self, name):
'''
Returns a new PluginSet that has only the plugins in this that are
named `name`.
'''
return PluginSet(self.group, name, [
plug for plug in self.plugins if plug.name == name]) | [
"def",
"select",
"(",
"self",
",",
"name",
")",
":",
"return",
"PluginSet",
"(",
"self",
".",
"group",
",",
"name",
",",
"[",
"plug",
"for",
"plug",
"in",
"self",
".",
"plugins",
"if",
"plug",
".",
"name",
"==",
"name",
"]",
")"
] | Returns a new PluginSet that has only the plugins in this that are
named `name`. | [
"Returns",
"a",
"new",
"PluginSet",
"that",
"has",
"only",
"the",
"plugins",
"in",
"this",
"that",
"are",
"named",
"name",
"."
] | f2c5e599cd4688f82216d4b5cfa87aab96d8bb8c | https://github.com/metagriffin/asset/blob/f2c5e599cd4688f82216d4b5cfa87aab96d8bb8c/asset/plugin.py#L86-L92 |
41,352 | MacHu-GWU/crawl_zillow-project | crawl_zillow/urlbuilder.py | UrlBuilder.browse_home_listpage_url | def browse_home_listpage_url(self,
state=None,
county=None,
zipcode=None,
street=None,
**kwargs):
"""
Construct an url of home list page by... | python | def browse_home_listpage_url(self,
state=None,
county=None,
zipcode=None,
street=None,
**kwargs):
"""
Construct an url of home list page by... | [
"def",
"browse_home_listpage_url",
"(",
"self",
",",
"state",
"=",
"None",
",",
"county",
"=",
"None",
",",
"zipcode",
"=",
"None",
",",
"street",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"url",
"=",
"self",
".",
"domain_browse_homes",
"for",
"i... | Construct an url of home list page by state, county, zipcode, street.
Example:
- https://www.zillow.com/browse/homes/ca/
- https://www.zillow.com/browse/homes/ca/los-angeles-county/
- https://www.zillow.com/browse/homes/ca/los-angeles-county/91001/
- https://www.zillow.com/brow... | [
"Construct",
"an",
"url",
"of",
"home",
"list",
"page",
"by",
"state",
"county",
"zipcode",
"street",
"."
] | c6d7ca8e4c80e7e7e963496433ef73df1413c16e | https://github.com/MacHu-GWU/crawl_zillow-project/blob/c6d7ca8e4c80e7e7e963496433ef73df1413c16e/crawl_zillow/urlbuilder.py#L12-L33 |
41,353 | sdcooke/django_bundles | django_bundles/templatetags/django_bundles_tags.py | _render_bundle | def _render_bundle(bundle_name):
"""
Renders the HTML for a bundle in place - one HTML tag or many depending on settings.USE_BUNDLES
"""
try:
bundle = get_bundles()[bundle_name]
except KeyError:
raise ImproperlyConfigured("Bundle '%s' is not defined" % bundle_name)
if bundle.use... | python | def _render_bundle(bundle_name):
"""
Renders the HTML for a bundle in place - one HTML tag or many depending on settings.USE_BUNDLES
"""
try:
bundle = get_bundles()[bundle_name]
except KeyError:
raise ImproperlyConfigured("Bundle '%s' is not defined" % bundle_name)
if bundle.use... | [
"def",
"_render_bundle",
"(",
"bundle_name",
")",
":",
"try",
":",
"bundle",
"=",
"get_bundles",
"(",
")",
"[",
"bundle_name",
"]",
"except",
"KeyError",
":",
"raise",
"ImproperlyConfigured",
"(",
"\"Bundle '%s' is not defined\"",
"%",
"bundle_name",
")",
"if",
... | Renders the HTML for a bundle in place - one HTML tag or many depending on settings.USE_BUNDLES | [
"Renders",
"the",
"HTML",
"for",
"a",
"bundle",
"in",
"place",
"-",
"one",
"HTML",
"tag",
"or",
"many",
"depending",
"on",
"settings",
".",
"USE_BUNDLES"
] | 2810fc455ec7391283792c1f108f4e8340f5d12f | https://github.com/sdcooke/django_bundles/blob/2810fc455ec7391283792c1f108f4e8340f5d12f/django_bundles/templatetags/django_bundles_tags.py#L23-L44 |
41,354 | helixyte/everest | everest/representers/base.py | Representer.from_string | def from_string(self, string_representation, resource=None):
"""
Extracts resource data from the given string and converts them to
a new resource or updates the given resource from it.
"""
stream = NativeIO(string_representation)
return self.from_stream(stream, resource=r... | python | def from_string(self, string_representation, resource=None):
"""
Extracts resource data from the given string and converts them to
a new resource or updates the given resource from it.
"""
stream = NativeIO(string_representation)
return self.from_stream(stream, resource=r... | [
"def",
"from_string",
"(",
"self",
",",
"string_representation",
",",
"resource",
"=",
"None",
")",
":",
"stream",
"=",
"NativeIO",
"(",
"string_representation",
")",
"return",
"self",
".",
"from_stream",
"(",
"stream",
",",
"resource",
"=",
"resource",
")"
] | Extracts resource data from the given string and converts them to
a new resource or updates the given resource from it. | [
"Extracts",
"resource",
"data",
"from",
"the",
"given",
"string",
"and",
"converts",
"them",
"to",
"a",
"new",
"resource",
"or",
"updates",
"the",
"given",
"resource",
"from",
"it",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/representers/base.py#L38-L44 |
41,355 | helixyte/everest | everest/representers/base.py | Representer.to_string | def to_string(self, obj):
"""
Converts the given resource to a string representation and returns
it.
"""
stream = NativeIO()
self.to_stream(obj, stream)
return text_(stream.getvalue(), encoding=self.encoding) | python | def to_string(self, obj):
"""
Converts the given resource to a string representation and returns
it.
"""
stream = NativeIO()
self.to_stream(obj, stream)
return text_(stream.getvalue(), encoding=self.encoding) | [
"def",
"to_string",
"(",
"self",
",",
"obj",
")",
":",
"stream",
"=",
"NativeIO",
"(",
")",
"self",
".",
"to_stream",
"(",
"obj",
",",
"stream",
")",
"return",
"text_",
"(",
"stream",
".",
"getvalue",
"(",
")",
",",
"encoding",
"=",
"self",
".",
"e... | Converts the given resource to a string representation and returns
it. | [
"Converts",
"the",
"given",
"resource",
"to",
"a",
"string",
"representation",
"and",
"returns",
"it",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/representers/base.py#L54-L61 |
41,356 | helixyte/everest | everest/representers/base.py | ResourceRepresenter.data_from_bytes | def data_from_bytes(self, byte_representation):
"""
Converts the given bytes representation to resource data.
"""
text = byte_representation.decode(self.encoding)
return self.data_from_string(text) | python | def data_from_bytes(self, byte_representation):
"""
Converts the given bytes representation to resource data.
"""
text = byte_representation.decode(self.encoding)
return self.data_from_string(text) | [
"def",
"data_from_bytes",
"(",
"self",
",",
"byte_representation",
")",
":",
"text",
"=",
"byte_representation",
".",
"decode",
"(",
"self",
".",
"encoding",
")",
"return",
"self",
".",
"data_from_string",
"(",
"text",
")"
] | Converts the given bytes representation to resource data. | [
"Converts",
"the",
"given",
"bytes",
"representation",
"to",
"resource",
"data",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/representers/base.py#L135-L140 |
41,357 | helixyte/everest | everest/representers/base.py | ResourceRepresenter.data_to_string | def data_to_string(self, data_element):
"""
Converts the given data element into a string representation.
:param data_element: object implementing
:class:`everest.representers.interfaces.IExplicitDataElement`
:returns: string representation (using the MIME content type
... | python | def data_to_string(self, data_element):
"""
Converts the given data element into a string representation.
:param data_element: object implementing
:class:`everest.representers.interfaces.IExplicitDataElement`
:returns: string representation (using the MIME content type
... | [
"def",
"data_to_string",
"(",
"self",
",",
"data_element",
")",
":",
"stream",
"=",
"NativeIO",
"(",
")",
"self",
".",
"data_to_stream",
"(",
"data_element",
",",
"stream",
")",
"return",
"stream",
".",
"getvalue",
"(",
")"
] | Converts the given data element into a string representation.
:param data_element: object implementing
:class:`everest.representers.interfaces.IExplicitDataElement`
:returns: string representation (using the MIME content type
configured for this representer) | [
"Converts",
"the",
"given",
"data",
"element",
"into",
"a",
"string",
"representation",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/representers/base.py#L142-L153 |
41,358 | helixyte/everest | everest/representers/base.py | MappingResourceRepresenter.create_from_resource_class | def create_from_resource_class(cls, resource_class):
"""
Creates a new representer for the given resource class.
The representer obtains a reference to the (freshly created or looked
up) mapping for the resource class.
"""
mp_reg = get_mapping_registry(cls.content_type)
... | python | def create_from_resource_class(cls, resource_class):
"""
Creates a new representer for the given resource class.
The representer obtains a reference to the (freshly created or looked
up) mapping for the resource class.
"""
mp_reg = get_mapping_registry(cls.content_type)
... | [
"def",
"create_from_resource_class",
"(",
"cls",
",",
"resource_class",
")",
":",
"mp_reg",
"=",
"get_mapping_registry",
"(",
"cls",
".",
"content_type",
")",
"mp",
"=",
"mp_reg",
".",
"find_or_create_mapping",
"(",
"resource_class",
")",
"return",
"cls",
"(",
"... | Creates a new representer for the given resource class.
The representer obtains a reference to the (freshly created or looked
up) mapping for the resource class. | [
"Creates",
"a",
"new",
"representer",
"for",
"the",
"given",
"resource",
"class",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/representers/base.py#L215-L224 |
41,359 | helixyte/everest | everest/representers/base.py | MappingResourceRepresenter.data_from_stream | def data_from_stream(self, stream):
"""
Creates a data element reading a representation from the given stream.
:returns: object implementing
:class:`everest.representers.interfaces.IExplicitDataElement`
"""
parser = self._make_representation_parser(stream, self.resou... | python | def data_from_stream(self, stream):
"""
Creates a data element reading a representation from the given stream.
:returns: object implementing
:class:`everest.representers.interfaces.IExplicitDataElement`
"""
parser = self._make_representation_parser(stream, self.resou... | [
"def",
"data_from_stream",
"(",
"self",
",",
"stream",
")",
":",
"parser",
"=",
"self",
".",
"_make_representation_parser",
"(",
"stream",
",",
"self",
".",
"resource_class",
",",
"self",
".",
"_mapping",
")",
"return",
"parser",
".",
"run",
"(",
")"
] | Creates a data element reading a representation from the given stream.
:returns: object implementing
:class:`everest.representers.interfaces.IExplicitDataElement` | [
"Creates",
"a",
"data",
"element",
"reading",
"a",
"representation",
"from",
"the",
"given",
"stream",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/representers/base.py#L230-L239 |
41,360 | helixyte/everest | everest/representers/base.py | MappingResourceRepresenter.data_to_stream | def data_to_stream(self, data_element, stream):
"""
Writes the given data element to the given stream.
"""
generator = \
self._make_representation_generator(stream, self.resource_class,
self._mapping)
generator.run(data_... | python | def data_to_stream(self, data_element, stream):
"""
Writes the given data element to the given stream.
"""
generator = \
self._make_representation_generator(stream, self.resource_class,
self._mapping)
generator.run(data_... | [
"def",
"data_to_stream",
"(",
"self",
",",
"data_element",
",",
"stream",
")",
":",
"generator",
"=",
"self",
".",
"_make_representation_generator",
"(",
"stream",
",",
"self",
".",
"resource_class",
",",
"self",
".",
"_mapping",
")",
"generator",
".",
"run",
... | Writes the given data element to the given stream. | [
"Writes",
"the",
"given",
"data",
"element",
"to",
"the",
"given",
"stream",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/representers/base.py#L241-L248 |
41,361 | helixyte/everest | everest/representers/base.py | MappingResourceRepresenter.resource_from_data | def resource_from_data(self, data_element, resource=None):
"""
Converts the given data element to a resource.
:param data_element: object implementing
:class:`everest.representers.interfaces.IExplicitDataElement`
"""
return self._mapping.map_to_resource(data_element,... | python | def resource_from_data(self, data_element, resource=None):
"""
Converts the given data element to a resource.
:param data_element: object implementing
:class:`everest.representers.interfaces.IExplicitDataElement`
"""
return self._mapping.map_to_resource(data_element,... | [
"def",
"resource_from_data",
"(",
"self",
",",
"data_element",
",",
"resource",
"=",
"None",
")",
":",
"return",
"self",
".",
"_mapping",
".",
"map_to_resource",
"(",
"data_element",
",",
"resource",
"=",
"resource",
")"
] | Converts the given data element to a resource.
:param data_element: object implementing
:class:`everest.representers.interfaces.IExplicitDataElement` | [
"Converts",
"the",
"given",
"data",
"element",
"to",
"a",
"resource",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/representers/base.py#L250-L257 |
41,362 | helixyte/everest | everest/representers/base.py | MappingResourceRepresenter.configure | def configure(self, options=None, attribute_options=None): # pylint: disable=W0221
"""
Configures the options and attribute options of the mapping associated
with this representer with the given dictionaries.
:param dict options: configuration options for the mapping associated
... | python | def configure(self, options=None, attribute_options=None): # pylint: disable=W0221
"""
Configures the options and attribute options of the mapping associated
with this representer with the given dictionaries.
:param dict options: configuration options for the mapping associated
... | [
"def",
"configure",
"(",
"self",
",",
"options",
"=",
"None",
",",
"attribute_options",
"=",
"None",
")",
":",
"# pylint: disable=W0221",
"self",
".",
"_mapping",
".",
"update",
"(",
"options",
"=",
"options",
",",
"attribute_options",
"=",
"attribute_options",
... | Configures the options and attribute options of the mapping associated
with this representer with the given dictionaries.
:param dict options: configuration options for the mapping associated
with this representer.
:param dict attribute_options: attribute options for the mapping
... | [
"Configures",
"the",
"options",
"and",
"attribute",
"options",
"of",
"the",
"mapping",
"associated",
"with",
"this",
"representer",
"with",
"the",
"given",
"dictionaries",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/representers/base.py#L278-L289 |
41,363 | helixyte/everest | everest/representers/base.py | MappingResourceRepresenter.with_updated_configuration | def with_updated_configuration(self, options=None,
attribute_options=None):
"""
Returns a context in which this representer is updated with the
given options and attribute options.
"""
return self._mapping.with_updated_configuration(options=opti... | python | def with_updated_configuration(self, options=None,
attribute_options=None):
"""
Returns a context in which this representer is updated with the
given options and attribute options.
"""
return self._mapping.with_updated_configuration(options=opti... | [
"def",
"with_updated_configuration",
"(",
"self",
",",
"options",
"=",
"None",
",",
"attribute_options",
"=",
"None",
")",
":",
"return",
"self",
".",
"_mapping",
".",
"with_updated_configuration",
"(",
"options",
"=",
"options",
",",
"attribute_options",
"=",
"... | Returns a context in which this representer is updated with the
given options and attribute options. | [
"Returns",
"a",
"context",
"in",
"which",
"this",
"representer",
"is",
"updated",
"with",
"the",
"given",
"options",
"and",
"attribute",
"options",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/representers/base.py#L294-L302 |
41,364 | brmscheiner/ideogram | ideogram/writer.py | jsPath | def jsPath(path):
'''Returns a relative path without \, -, and . so that
the string will play nicely with javascript.'''
shortPath=path.replace(
"C:\\Users\\scheinerbock\\Desktop\\"+
"ideogram\\scrapeSource\\test\\","")
noDash = shortPath.replace("-","_dash_")
jsPath=noDash.... | python | def jsPath(path):
'''Returns a relative path without \, -, and . so that
the string will play nicely with javascript.'''
shortPath=path.replace(
"C:\\Users\\scheinerbock\\Desktop\\"+
"ideogram\\scrapeSource\\test\\","")
noDash = shortPath.replace("-","_dash_")
jsPath=noDash.... | [
"def",
"jsPath",
"(",
"path",
")",
":",
"shortPath",
"=",
"path",
".",
"replace",
"(",
"\"C:\\\\Users\\\\scheinerbock\\\\Desktop\\\\\"",
"+",
"\"ideogram\\\\scrapeSource\\\\test\\\\\"",
",",
"\"\"",
")",
"noDash",
"=",
"shortPath",
".",
"replace",
"(",
"\"-\"",
",",... | Returns a relative path without \, -, and . so that
the string will play nicely with javascript. | [
"Returns",
"a",
"relative",
"path",
"without",
"\\",
"-",
"and",
".",
"so",
"that",
"the",
"string",
"will",
"play",
"nicely",
"with",
"javascript",
"."
] | 422bf566c51fd56f7bbb6e75b16d18d52b4c7568 | https://github.com/brmscheiner/ideogram/blob/422bf566c51fd56f7bbb6e75b16d18d52b4c7568/ideogram/writer.py#L3-L11 |
41,365 | brmscheiner/ideogram | ideogram/writer.py | jsName | def jsName(path,name):
'''Returns a name string without \, -, and . so that
the string will play nicely with javascript.'''
shortPath=path.replace(
"C:\\Users\\scheinerbock\\Desktop\\"+
"ideogram\\scrapeSource\\test\\","")
noDash = shortPath.replace("-","_dash_")
jsPath=noDa... | python | def jsName(path,name):
'''Returns a name string without \, -, and . so that
the string will play nicely with javascript.'''
shortPath=path.replace(
"C:\\Users\\scheinerbock\\Desktop\\"+
"ideogram\\scrapeSource\\test\\","")
noDash = shortPath.replace("-","_dash_")
jsPath=noDa... | [
"def",
"jsName",
"(",
"path",
",",
"name",
")",
":",
"shortPath",
"=",
"path",
".",
"replace",
"(",
"\"C:\\\\Users\\\\scheinerbock\\\\Desktop\\\\\"",
"+",
"\"ideogram\\\\scrapeSource\\\\test\\\\\"",
",",
"\"\"",
")",
"noDash",
"=",
"shortPath",
".",
"replace",
"(",
... | Returns a name string without \, -, and . so that
the string will play nicely with javascript. | [
"Returns",
"a",
"name",
"string",
"without",
"\\",
"-",
"and",
".",
"so",
"that",
"the",
"string",
"will",
"play",
"nicely",
"with",
"javascript",
"."
] | 422bf566c51fd56f7bbb6e75b16d18d52b4c7568 | https://github.com/brmscheiner/ideogram/blob/422bf566c51fd56f7bbb6e75b16d18d52b4c7568/ideogram/writer.py#L13-L22 |
41,366 | brmscheiner/ideogram | ideogram/writer.py | getStartNodes | def getStartNodes(fdefs,calls):
'''Return a list of nodes in fdefs that have no inbound edges'''
s=[]
for source in fdefs:
for fn in fdefs[source]:
inboundEdges=False
for call in calls:
if call.target==fn:
inboundEdges=True
if n... | python | def getStartNodes(fdefs,calls):
'''Return a list of nodes in fdefs that have no inbound edges'''
s=[]
for source in fdefs:
for fn in fdefs[source]:
inboundEdges=False
for call in calls:
if call.target==fn:
inboundEdges=True
if n... | [
"def",
"getStartNodes",
"(",
"fdefs",
",",
"calls",
")",
":",
"s",
"=",
"[",
"]",
"for",
"source",
"in",
"fdefs",
":",
"for",
"fn",
"in",
"fdefs",
"[",
"source",
"]",
":",
"inboundEdges",
"=",
"False",
"for",
"call",
"in",
"calls",
":",
"if",
"call... | Return a list of nodes in fdefs that have no inbound edges | [
"Return",
"a",
"list",
"of",
"nodes",
"in",
"fdefs",
"that",
"have",
"no",
"inbound",
"edges"
] | 422bf566c51fd56f7bbb6e75b16d18d52b4c7568 | https://github.com/brmscheiner/ideogram/blob/422bf566c51fd56f7bbb6e75b16d18d52b4c7568/ideogram/writer.py#L55-L66 |
41,367 | brmscheiner/ideogram | ideogram/writer.py | getChildren | def getChildren(current,calls,blacklist=[]):
''' Return a list of the children of current that are not in used. '''
return [c.target for c in calls if c.source==current and c.target not in blacklist] | python | def getChildren(current,calls,blacklist=[]):
''' Return a list of the children of current that are not in used. '''
return [c.target for c in calls if c.source==current and c.target not in blacklist] | [
"def",
"getChildren",
"(",
"current",
",",
"calls",
",",
"blacklist",
"=",
"[",
"]",
")",
":",
"return",
"[",
"c",
".",
"target",
"for",
"c",
"in",
"calls",
"if",
"c",
".",
"source",
"==",
"current",
"and",
"c",
".",
"target",
"not",
"in",
"blackli... | Return a list of the children of current that are not in used. | [
"Return",
"a",
"list",
"of",
"the",
"children",
"of",
"current",
"that",
"are",
"not",
"in",
"used",
"."
] | 422bf566c51fd56f7bbb6e75b16d18d52b4c7568 | https://github.com/brmscheiner/ideogram/blob/422bf566c51fd56f7bbb6e75b16d18d52b4c7568/ideogram/writer.py#L140-L142 |
41,368 | brmscheiner/ideogram | ideogram/writer.py | tagAttributes | def tagAttributes(fdef_master_list,node,depth=0):
'''recursively tag objects with sizes, depths and path names '''
if type(node)==list:
for i in node:
depth+=1
tagAttributes(fdef_master_list,i,depth)
if type(node)==dict:
for x in fdef_master_list:
if jsNam... | python | def tagAttributes(fdef_master_list,node,depth=0):
'''recursively tag objects with sizes, depths and path names '''
if type(node)==list:
for i in node:
depth+=1
tagAttributes(fdef_master_list,i,depth)
if type(node)==dict:
for x in fdef_master_list:
if jsNam... | [
"def",
"tagAttributes",
"(",
"fdef_master_list",
",",
"node",
",",
"depth",
"=",
"0",
")",
":",
"if",
"type",
"(",
"node",
")",
"==",
"list",
":",
"for",
"i",
"in",
"node",
":",
"depth",
"+=",
"1",
"tagAttributes",
"(",
"fdef_master_list",
",",
"i",
... | recursively tag objects with sizes, depths and path names | [
"recursively",
"tag",
"objects",
"with",
"sizes",
"depths",
"and",
"path",
"names"
] | 422bf566c51fd56f7bbb6e75b16d18d52b4c7568 | https://github.com/brmscheiner/ideogram/blob/422bf566c51fd56f7bbb6e75b16d18d52b4c7568/ideogram/writer.py#L161-L177 |
41,369 | brmscheiner/ideogram | ideogram/writer.py | tagAttributes_while | def tagAttributes_while(fdef_master_list,root):
'''Tag each node under root with the appropriate depth. '''
depth = 0
current = root
untagged_nodes = [root]
while untagged_nodes:
current = untagged_nodes.pop()
for x in fdef_master_list:
if jsName(x.path,x.name) == current... | python | def tagAttributes_while(fdef_master_list,root):
'''Tag each node under root with the appropriate depth. '''
depth = 0
current = root
untagged_nodes = [root]
while untagged_nodes:
current = untagged_nodes.pop()
for x in fdef_master_list:
if jsName(x.path,x.name) == current... | [
"def",
"tagAttributes_while",
"(",
"fdef_master_list",
",",
"root",
")",
":",
"depth",
"=",
"0",
"current",
"=",
"root",
"untagged_nodes",
"=",
"[",
"root",
"]",
"while",
"untagged_nodes",
":",
"current",
"=",
"untagged_nodes",
".",
"pop",
"(",
")",
"for",
... | Tag each node under root with the appropriate depth. | [
"Tag",
"each",
"node",
"under",
"root",
"with",
"the",
"appropriate",
"depth",
"."
] | 422bf566c51fd56f7bbb6e75b16d18d52b4c7568 | https://github.com/brmscheiner/ideogram/blob/422bf566c51fd56f7bbb6e75b16d18d52b4c7568/ideogram/writer.py#L179-L196 |
41,370 | brmscheiner/ideogram | ideogram/writer.py | noEmptyNests | def noEmptyNests(node):
'''recursively make sure that no dictionaries inside node contain empty children lists '''
if type(node)==list:
for i in node:
noEmptyNests(i)
if type(node)==dict:
for i in node.values():
noEmptyNests(i)
if node["children"] == []:
... | python | def noEmptyNests(node):
'''recursively make sure that no dictionaries inside node contain empty children lists '''
if type(node)==list:
for i in node:
noEmptyNests(i)
if type(node)==dict:
for i in node.values():
noEmptyNests(i)
if node["children"] == []:
... | [
"def",
"noEmptyNests",
"(",
"node",
")",
":",
"if",
"type",
"(",
"node",
")",
"==",
"list",
":",
"for",
"i",
"in",
"node",
":",
"noEmptyNests",
"(",
"i",
")",
"if",
"type",
"(",
"node",
")",
"==",
"dict",
":",
"for",
"i",
"in",
"node",
".",
"va... | recursively make sure that no dictionaries inside node contain empty children lists | [
"recursively",
"make",
"sure",
"that",
"no",
"dictionaries",
"inside",
"node",
"contain",
"empty",
"children",
"lists"
] | 422bf566c51fd56f7bbb6e75b16d18d52b4c7568 | https://github.com/brmscheiner/ideogram/blob/422bf566c51fd56f7bbb6e75b16d18d52b4c7568/ideogram/writer.py#L199-L209 |
41,371 | liminspace/dju-image | dju_image/maintenance.py | remove_old_tmp_files | def remove_old_tmp_files(profiles=None, max_lifetime=(7 * 24)):
"""
Removes old temp files that is older than expiration_hours.
If profiles is None then will be use all profiles.
"""
assert isinstance(profiles, (list, tuple)) or profiles is None
if profiles is None:
profiles = dju_settin... | python | def remove_old_tmp_files(profiles=None, max_lifetime=(7 * 24)):
"""
Removes old temp files that is older than expiration_hours.
If profiles is None then will be use all profiles.
"""
assert isinstance(profiles, (list, tuple)) or profiles is None
if profiles is None:
profiles = dju_settin... | [
"def",
"remove_old_tmp_files",
"(",
"profiles",
"=",
"None",
",",
"max_lifetime",
"=",
"(",
"7",
"*",
"24",
")",
")",
":",
"assert",
"isinstance",
"(",
"profiles",
",",
"(",
"list",
",",
"tuple",
")",
")",
"or",
"profiles",
"is",
"None",
"if",
"profile... | Removes old temp files that is older than expiration_hours.
If profiles is None then will be use all profiles. | [
"Removes",
"old",
"temp",
"files",
"that",
"is",
"older",
"than",
"expiration_hours",
".",
"If",
"profiles",
"is",
"None",
"then",
"will",
"be",
"use",
"all",
"profiles",
"."
] | b06eb3be2069cd6cb52cf1e26c2c761883142d4e | https://github.com/liminspace/dju-image/blob/b06eb3be2069cd6cb52cf1e26c2c761883142d4e/dju_image/maintenance.py#L23-L46 |
41,372 | erikvw/django-collect-offline-files | django_collect_offline_files/file_queues/incoming_transactions_file_queue.py | IncomingTransactionsFileQueue.next_task | def next_task(self, item, **kwargs):
"""Calls import_batch for the next filename in the queue
and "archives" the file.
The archive folder is typically the folder for the deserializer queue.
"""
filename = os.path.basename(item)
try:
self.tx_importer.import_ba... | python | def next_task(self, item, **kwargs):
"""Calls import_batch for the next filename in the queue
and "archives" the file.
The archive folder is typically the folder for the deserializer queue.
"""
filename = os.path.basename(item)
try:
self.tx_importer.import_ba... | [
"def",
"next_task",
"(",
"self",
",",
"item",
",",
"*",
"*",
"kwargs",
")",
":",
"filename",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"item",
")",
"try",
":",
"self",
".",
"tx_importer",
".",
"import_batch",
"(",
"filename",
"=",
"filename",
")"... | Calls import_batch for the next filename in the queue
and "archives" the file.
The archive folder is typically the folder for the deserializer queue. | [
"Calls",
"import_batch",
"for",
"the",
"next",
"filename",
"in",
"the",
"queue",
"and",
"archives",
"the",
"file",
"."
] | 78f61c823ea3926eb88206b019b5dca3c36017da | https://github.com/erikvw/django-collect-offline-files/blob/78f61c823ea3926eb88206b019b5dca3c36017da/django_collect_offline_files/file_queues/incoming_transactions_file_queue.py#L17-L29 |
41,373 | django-fluent/django-fluent-utils | fluent_utils/softdeps/comments.py | get_public_comments_for_model | def get_public_comments_for_model(model):
"""
Get visible comments for the model.
"""
if not IS_INSTALLED:
# No local comments, return empty queryset.
# The project might be using DISQUS or Facebook comments instead.
return CommentModelStub.objects.none()
else:
return... | python | def get_public_comments_for_model(model):
"""
Get visible comments for the model.
"""
if not IS_INSTALLED:
# No local comments, return empty queryset.
# The project might be using DISQUS or Facebook comments instead.
return CommentModelStub.objects.none()
else:
return... | [
"def",
"get_public_comments_for_model",
"(",
"model",
")",
":",
"if",
"not",
"IS_INSTALLED",
":",
"# No local comments, return empty queryset.",
"# The project might be using DISQUS or Facebook comments instead.",
"return",
"CommentModelStub",
".",
"objects",
".",
"none",
"(",
... | Get visible comments for the model. | [
"Get",
"visible",
"comments",
"for",
"the",
"model",
"."
] | 5f93e5aa20f33a44133ad49fde4df0bfe1bc9f0b | https://github.com/django-fluent/django-fluent-utils/blob/5f93e5aa20f33a44133ad49fde4df0bfe1bc9f0b/fluent_utils/softdeps/comments.py#L67-L76 |
41,374 | django-fluent/django-fluent-utils | fluent_utils/softdeps/comments.py | get_comments_are_open | def get_comments_are_open(instance):
"""
Check if comments are open for the instance
"""
if not IS_INSTALLED:
return False
try:
# Get the moderator which is installed for this model.
mod = moderator._registry[instance.__class__]
except KeyError:
# No moderator = ... | python | def get_comments_are_open(instance):
"""
Check if comments are open for the instance
"""
if not IS_INSTALLED:
return False
try:
# Get the moderator which is installed for this model.
mod = moderator._registry[instance.__class__]
except KeyError:
# No moderator = ... | [
"def",
"get_comments_are_open",
"(",
"instance",
")",
":",
"if",
"not",
"IS_INSTALLED",
":",
"return",
"False",
"try",
":",
"# Get the moderator which is installed for this model.",
"mod",
"=",
"moderator",
".",
"_registry",
"[",
"instance",
".",
"__class__",
"]",
"... | Check if comments are open for the instance | [
"Check",
"if",
"comments",
"are",
"open",
"for",
"the",
"instance"
] | 5f93e5aa20f33a44133ad49fde4df0bfe1bc9f0b | https://github.com/django-fluent/django-fluent-utils/blob/5f93e5aa20f33a44133ad49fde4df0bfe1bc9f0b/fluent_utils/softdeps/comments.py#L79-L95 |
41,375 | django-fluent/django-fluent-utils | fluent_utils/softdeps/comments.py | get_comments_are_moderated | def get_comments_are_moderated(instance):
"""
Check if comments are moderated for the instance
"""
if not IS_INSTALLED:
return False
try:
# Get the moderator which is installed for this model.
mod = moderator._registry[instance.__class__]
except KeyError:
# No mo... | python | def get_comments_are_moderated(instance):
"""
Check if comments are moderated for the instance
"""
if not IS_INSTALLED:
return False
try:
# Get the moderator which is installed for this model.
mod = moderator._registry[instance.__class__]
except KeyError:
# No mo... | [
"def",
"get_comments_are_moderated",
"(",
"instance",
")",
":",
"if",
"not",
"IS_INSTALLED",
":",
"return",
"False",
"try",
":",
"# Get the moderator which is installed for this model.",
"mod",
"=",
"moderator",
".",
"_registry",
"[",
"instance",
".",
"__class__",
"]"... | Check if comments are moderated for the instance | [
"Check",
"if",
"comments",
"are",
"moderated",
"for",
"the",
"instance"
] | 5f93e5aa20f33a44133ad49fde4df0bfe1bc9f0b | https://github.com/django-fluent/django-fluent-utils/blob/5f93e5aa20f33a44133ad49fde4df0bfe1bc9f0b/fluent_utils/softdeps/comments.py#L98-L114 |
41,376 | cstatz/maui | maui/backend/helper.py | calc_local_indices | def calc_local_indices(shape, num_partitions, coordinate):
""" calculate local indices, return start and stop index per dimension per process for local data field
:param shape: global shape of data
:param num_partitions: number of partition for each dimension (from MPI.Compute_dims())
:param coordinate... | python | def calc_local_indices(shape, num_partitions, coordinate):
""" calculate local indices, return start and stop index per dimension per process for local data field
:param shape: global shape of data
:param num_partitions: number of partition for each dimension (from MPI.Compute_dims())
:param coordinate... | [
"def",
"calc_local_indices",
"(",
"shape",
",",
"num_partitions",
",",
"coordinate",
")",
":",
"dimension",
"=",
"len",
"(",
"shape",
")",
"# check matching of cartesian communicator and shape",
"assert",
"dimension",
"==",
"len",
"(",
"num_partitions",
")",
"decompos... | calculate local indices, return start and stop index per dimension per process for local data field
:param shape: global shape of data
:param num_partitions: number of partition for each dimension (from MPI.Compute_dims())
:param coordinate: cartesian coordinate descriptor (from CARTESIAN_COMMUNICATOR.Get_... | [
"calculate",
"local",
"indices",
"return",
"start",
"and",
"stop",
"index",
"per",
"dimension",
"per",
"process",
"for",
"local",
"data",
"field"
] | db99986e93699ee20c5cffdd5b4ee446f8607c5d | https://github.com/cstatz/maui/blob/db99986e93699ee20c5cffdd5b4ee446f8607c5d/maui/backend/helper.py#L85-L146 |
41,377 | Nekroze/partpy | partpy/sourcestring.py | SourceString.load_file | def load_file(self, filename):
"""Read in file contents and set the current string."""
with open(filename, 'r') as sourcefile:
self.set_string(sourcefile.read()) | python | def load_file(self, filename):
"""Read in file contents and set the current string."""
with open(filename, 'r') as sourcefile:
self.set_string(sourcefile.read()) | [
"def",
"load_file",
"(",
"self",
",",
"filename",
")",
":",
"with",
"open",
"(",
"filename",
",",
"'r'",
")",
"as",
"sourcefile",
":",
"self",
".",
"set_string",
"(",
"sourcefile",
".",
"read",
"(",
")",
")"
] | Read in file contents and set the current string. | [
"Read",
"in",
"file",
"contents",
"and",
"set",
"the",
"current",
"string",
"."
] | dbb7d2fb285464fc43d85bc31f5af46192d301f6 | https://github.com/Nekroze/partpy/blob/dbb7d2fb285464fc43d85bc31f5af46192d301f6/partpy/sourcestring.py#L33-L36 |
41,378 | Nekroze/partpy | partpy/sourcestring.py | SourceString.set_string | def set_string(self, string):
"""Set the working string and its length then reset positions."""
self.string = string
self.length = len(string)
self.reset_position() | python | def set_string(self, string):
"""Set the working string and its length then reset positions."""
self.string = string
self.length = len(string)
self.reset_position() | [
"def",
"set_string",
"(",
"self",
",",
"string",
")",
":",
"self",
".",
"string",
"=",
"string",
"self",
".",
"length",
"=",
"len",
"(",
"string",
")",
"self",
".",
"reset_position",
"(",
")"
] | Set the working string and its length then reset positions. | [
"Set",
"the",
"working",
"string",
"and",
"its",
"length",
"then",
"reset",
"positions",
"."
] | dbb7d2fb285464fc43d85bc31f5af46192d301f6 | https://github.com/Nekroze/partpy/blob/dbb7d2fb285464fc43d85bc31f5af46192d301f6/partpy/sourcestring.py#L38-L42 |
41,379 | Nekroze/partpy | partpy/sourcestring.py | SourceString.add_string | def add_string(self, string):
"""Add to the working string and its length and reset eos."""
self.string += string
self.length += len(string)
self.eos = 0 | python | def add_string(self, string):
"""Add to the working string and its length and reset eos."""
self.string += string
self.length += len(string)
self.eos = 0 | [
"def",
"add_string",
"(",
"self",
",",
"string",
")",
":",
"self",
".",
"string",
"+=",
"string",
"self",
".",
"length",
"+=",
"len",
"(",
"string",
")",
"self",
".",
"eos",
"=",
"0"
] | Add to the working string and its length and reset eos. | [
"Add",
"to",
"the",
"working",
"string",
"and",
"its",
"length",
"and",
"reset",
"eos",
"."
] | dbb7d2fb285464fc43d85bc31f5af46192d301f6 | https://github.com/Nekroze/partpy/blob/dbb7d2fb285464fc43d85bc31f5af46192d301f6/partpy/sourcestring.py#L44-L48 |
41,380 | Nekroze/partpy | partpy/sourcestring.py | SourceString.reset_position | def reset_position(self):
"""Reset all current positions."""
self.pos = 0
self.col = 0
self.row = 1
self.eos = 0 | python | def reset_position(self):
"""Reset all current positions."""
self.pos = 0
self.col = 0
self.row = 1
self.eos = 0 | [
"def",
"reset_position",
"(",
"self",
")",
":",
"self",
".",
"pos",
"=",
"0",
"self",
".",
"col",
"=",
"0",
"self",
".",
"row",
"=",
"1",
"self",
".",
"eos",
"=",
"0"
] | Reset all current positions. | [
"Reset",
"all",
"current",
"positions",
"."
] | dbb7d2fb285464fc43d85bc31f5af46192d301f6 | https://github.com/Nekroze/partpy/blob/dbb7d2fb285464fc43d85bc31f5af46192d301f6/partpy/sourcestring.py#L50-L55 |
41,381 | Nekroze/partpy | partpy/sourcestring.py | SourceString.has_space | def has_space(self, length=1, offset=0):
"""Returns boolean if self.pos + length < working string length."""
return self.pos + (length + offset) - 1 < self.length | python | def has_space(self, length=1, offset=0):
"""Returns boolean if self.pos + length < working string length."""
return self.pos + (length + offset) - 1 < self.length | [
"def",
"has_space",
"(",
"self",
",",
"length",
"=",
"1",
",",
"offset",
"=",
"0",
")",
":",
"return",
"self",
".",
"pos",
"+",
"(",
"length",
"+",
"offset",
")",
"-",
"1",
"<",
"self",
".",
"length"
] | Returns boolean if self.pos + length < working string length. | [
"Returns",
"boolean",
"if",
"self",
".",
"pos",
"+",
"length",
"<",
"working",
"string",
"length",
"."
] | dbb7d2fb285464fc43d85bc31f5af46192d301f6 | https://github.com/Nekroze/partpy/blob/dbb7d2fb285464fc43d85bc31f5af46192d301f6/partpy/sourcestring.py#L57-L59 |
41,382 | Nekroze/partpy | partpy/sourcestring.py | SourceString.eol_distance_next | def eol_distance_next(self, offset=0):
"""Return the amount of characters until the next newline."""
distance = 0
for char in self.string[self.pos + offset:]:
if char == '\n':
break
else:
distance += 1
return distance | python | def eol_distance_next(self, offset=0):
"""Return the amount of characters until the next newline."""
distance = 0
for char in self.string[self.pos + offset:]:
if char == '\n':
break
else:
distance += 1
return distance | [
"def",
"eol_distance_next",
"(",
"self",
",",
"offset",
"=",
"0",
")",
":",
"distance",
"=",
"0",
"for",
"char",
"in",
"self",
".",
"string",
"[",
"self",
".",
"pos",
"+",
"offset",
":",
"]",
":",
"if",
"char",
"==",
"'\\n'",
":",
"break",
"else",
... | Return the amount of characters until the next newline. | [
"Return",
"the",
"amount",
"of",
"characters",
"until",
"the",
"next",
"newline",
"."
] | dbb7d2fb285464fc43d85bc31f5af46192d301f6 | https://github.com/Nekroze/partpy/blob/dbb7d2fb285464fc43d85bc31f5af46192d301f6/partpy/sourcestring.py#L61-L69 |
41,383 | Nekroze/partpy | partpy/sourcestring.py | SourceString.eol_distance_last | def eol_distance_last(self, offset=0):
"""Return the ammount of characters until the last newline."""
distance = 0
for char in reversed(self.string[:self.pos + offset]):
if char == '\n':
break
else:
distance += 1
return distance | python | def eol_distance_last(self, offset=0):
"""Return the ammount of characters until the last newline."""
distance = 0
for char in reversed(self.string[:self.pos + offset]):
if char == '\n':
break
else:
distance += 1
return distance | [
"def",
"eol_distance_last",
"(",
"self",
",",
"offset",
"=",
"0",
")",
":",
"distance",
"=",
"0",
"for",
"char",
"in",
"reversed",
"(",
"self",
".",
"string",
"[",
":",
"self",
".",
"pos",
"+",
"offset",
"]",
")",
":",
"if",
"char",
"==",
"'\\n'",
... | Return the ammount of characters until the last newline. | [
"Return",
"the",
"ammount",
"of",
"characters",
"until",
"the",
"last",
"newline",
"."
] | dbb7d2fb285464fc43d85bc31f5af46192d301f6 | https://github.com/Nekroze/partpy/blob/dbb7d2fb285464fc43d85bc31f5af46192d301f6/partpy/sourcestring.py#L71-L79 |
41,384 | Nekroze/partpy | partpy/sourcestring.py | SourceString.spew_length | def spew_length(self, length):
"""Move current position backwards by length."""
pos = self.pos
if not pos or length > pos:
return None
row = self.row
for char in reversed(self.string[pos - length:pos]):
pos -= 1
if char == '\n': # handle a ne... | python | def spew_length(self, length):
"""Move current position backwards by length."""
pos = self.pos
if not pos or length > pos:
return None
row = self.row
for char in reversed(self.string[pos - length:pos]):
pos -= 1
if char == '\n': # handle a ne... | [
"def",
"spew_length",
"(",
"self",
",",
"length",
")",
":",
"pos",
"=",
"self",
".",
"pos",
"if",
"not",
"pos",
"or",
"length",
">",
"pos",
":",
"return",
"None",
"row",
"=",
"self",
".",
"row",
"for",
"char",
"in",
"reversed",
"(",
"self",
".",
... | Move current position backwards by length. | [
"Move",
"current",
"position",
"backwards",
"by",
"length",
"."
] | dbb7d2fb285464fc43d85bc31f5af46192d301f6 | https://github.com/Nekroze/partpy/blob/dbb7d2fb285464fc43d85bc31f5af46192d301f6/partpy/sourcestring.py#L81-L98 |
41,385 | Nekroze/partpy | partpy/sourcestring.py | SourceString.eat_length | def eat_length(self, length):
"""Move current position forward by length and sets eos if needed."""
pos = self.pos
if self.eos or pos + length > self.length:
return None
col = self.col
row = self.row
for char in self.string[pos:pos + length]:
col ... | python | def eat_length(self, length):
"""Move current position forward by length and sets eos if needed."""
pos = self.pos
if self.eos or pos + length > self.length:
return None
col = self.col
row = self.row
for char in self.string[pos:pos + length]:
col ... | [
"def",
"eat_length",
"(",
"self",
",",
"length",
")",
":",
"pos",
"=",
"self",
".",
"pos",
"if",
"self",
".",
"eos",
"or",
"pos",
"+",
"length",
">",
"self",
".",
"length",
":",
"return",
"None",
"col",
"=",
"self",
".",
"col",
"row",
"=",
"self"... | Move current position forward by length and sets eos if needed. | [
"Move",
"current",
"position",
"forward",
"by",
"length",
"and",
"sets",
"eos",
"if",
"needed",
"."
] | dbb7d2fb285464fc43d85bc31f5af46192d301f6 | https://github.com/Nekroze/partpy/blob/dbb7d2fb285464fc43d85bc31f5af46192d301f6/partpy/sourcestring.py#L100-L120 |
41,386 | Nekroze/partpy | partpy/sourcestring.py | SourceString.eat_string | def eat_string(self, string):
"""Move current position by length of string and count lines by \n."""
pos = self.pos
if self.eos or pos + len(string) > self.length:
return None
col = self.col
row = self.row
for char in string:
col += 1
... | python | def eat_string(self, string):
"""Move current position by length of string and count lines by \n."""
pos = self.pos
if self.eos or pos + len(string) > self.length:
return None
col = self.col
row = self.row
for char in string:
col += 1
... | [
"def",
"eat_string",
"(",
"self",
",",
"string",
")",
":",
"pos",
"=",
"self",
".",
"pos",
"if",
"self",
".",
"eos",
"or",
"pos",
"+",
"len",
"(",
"string",
")",
">",
"self",
".",
"length",
":",
"return",
"None",
"col",
"=",
"self",
".",
"col",
... | Move current position by length of string and count lines by \n. | [
"Move",
"current",
"position",
"by",
"length",
"of",
"string",
"and",
"count",
"lines",
"by",
"\\",
"n",
"."
] | dbb7d2fb285464fc43d85bc31f5af46192d301f6 | https://github.com/Nekroze/partpy/blob/dbb7d2fb285464fc43d85bc31f5af46192d301f6/partpy/sourcestring.py#L122-L142 |
41,387 | Nekroze/partpy | partpy/sourcestring.py | SourceString.eat_line | def eat_line(self):
"""Move current position forward until the next line."""
if self.eos:
return None
eat_length = self.eat_length
get_char = self.get_char
has_space = self.has_space
while has_space() and get_char() != '\n':
eat_length(1)
e... | python | def eat_line(self):
"""Move current position forward until the next line."""
if self.eos:
return None
eat_length = self.eat_length
get_char = self.get_char
has_space = self.has_space
while has_space() and get_char() != '\n':
eat_length(1)
e... | [
"def",
"eat_line",
"(",
"self",
")",
":",
"if",
"self",
".",
"eos",
":",
"return",
"None",
"eat_length",
"=",
"self",
".",
"eat_length",
"get_char",
"=",
"self",
".",
"get_char",
"has_space",
"=",
"self",
".",
"has_space",
"while",
"has_space",
"(",
")",... | Move current position forward until the next line. | [
"Move",
"current",
"position",
"forward",
"until",
"the",
"next",
"line",
"."
] | dbb7d2fb285464fc43d85bc31f5af46192d301f6 | https://github.com/Nekroze/partpy/blob/dbb7d2fb285464fc43d85bc31f5af46192d301f6/partpy/sourcestring.py#L144-L153 |
41,388 | Nekroze/partpy | partpy/sourcestring.py | SourceString.get_char | def get_char(self, offset=0):
"""Return the current character in the working string."""
if not self.has_space(offset=offset):
return ''
return self.string[self.pos + offset] | python | def get_char(self, offset=0):
"""Return the current character in the working string."""
if not self.has_space(offset=offset):
return ''
return self.string[self.pos + offset] | [
"def",
"get_char",
"(",
"self",
",",
"offset",
"=",
"0",
")",
":",
"if",
"not",
"self",
".",
"has_space",
"(",
"offset",
"=",
"offset",
")",
":",
"return",
"''",
"return",
"self",
".",
"string",
"[",
"self",
".",
"pos",
"+",
"offset",
"]"
] | Return the current character in the working string. | [
"Return",
"the",
"current",
"character",
"in",
"the",
"working",
"string",
"."
] | dbb7d2fb285464fc43d85bc31f5af46192d301f6 | https://github.com/Nekroze/partpy/blob/dbb7d2fb285464fc43d85bc31f5af46192d301f6/partpy/sourcestring.py#L155-L160 |
41,389 | Nekroze/partpy | partpy/sourcestring.py | SourceString.get_length | def get_length(self, length, trim=0, offset=0):
"""Return string at current position + length.
If trim == true then get as much as possible before eos.
"""
if trim and not self.has_space(offset + length):
return self.string[self.pos + offset:]
elif self.has_space(offs... | python | def get_length(self, length, trim=0, offset=0):
"""Return string at current position + length.
If trim == true then get as much as possible before eos.
"""
if trim and not self.has_space(offset + length):
return self.string[self.pos + offset:]
elif self.has_space(offs... | [
"def",
"get_length",
"(",
"self",
",",
"length",
",",
"trim",
"=",
"0",
",",
"offset",
"=",
"0",
")",
":",
"if",
"trim",
"and",
"not",
"self",
".",
"has_space",
"(",
"offset",
"+",
"length",
")",
":",
"return",
"self",
".",
"string",
"[",
"self",
... | Return string at current position + length.
If trim == true then get as much as possible before eos. | [
"Return",
"string",
"at",
"current",
"position",
"+",
"length",
".",
"If",
"trim",
"==",
"true",
"then",
"get",
"as",
"much",
"as",
"possible",
"before",
"eos",
"."
] | dbb7d2fb285464fc43d85bc31f5af46192d301f6 | https://github.com/Nekroze/partpy/blob/dbb7d2fb285464fc43d85bc31f5af46192d301f6/partpy/sourcestring.py#L162-L171 |
41,390 | Nekroze/partpy | partpy/sourcestring.py | SourceString.get_string | def get_string(self, offset=0):
"""Return non space chars from current position until a whitespace."""
if not self.has_space(offset=offset):
return ''
# Get a char for each char in the current string from pos onward
# solong as the char is not whitespace.
string = s... | python | def get_string(self, offset=0):
"""Return non space chars from current position until a whitespace."""
if not self.has_space(offset=offset):
return ''
# Get a char for each char in the current string from pos onward
# solong as the char is not whitespace.
string = s... | [
"def",
"get_string",
"(",
"self",
",",
"offset",
"=",
"0",
")",
":",
"if",
"not",
"self",
".",
"has_space",
"(",
"offset",
"=",
"offset",
")",
":",
"return",
"''",
"# Get a char for each char in the current string from pos onward",
"# solong as the char is not whites... | Return non space chars from current position until a whitespace. | [
"Return",
"non",
"space",
"chars",
"from",
"current",
"position",
"until",
"a",
"whitespace",
"."
] | dbb7d2fb285464fc43d85bc31f5af46192d301f6 | https://github.com/Nekroze/partpy/blob/dbb7d2fb285464fc43d85bc31f5af46192d301f6/partpy/sourcestring.py#L173-L186 |
41,391 | Nekroze/partpy | partpy/sourcestring.py | SourceString.rest_of_string | def rest_of_string(self, offset=0):
"""A copy of the current position till the end of the source string."""
if self.has_space(offset=offset):
return self.string[self.pos + offset:]
else:
return '' | python | def rest_of_string(self, offset=0):
"""A copy of the current position till the end of the source string."""
if self.has_space(offset=offset):
return self.string[self.pos + offset:]
else:
return '' | [
"def",
"rest_of_string",
"(",
"self",
",",
"offset",
"=",
"0",
")",
":",
"if",
"self",
".",
"has_space",
"(",
"offset",
"=",
"offset",
")",
":",
"return",
"self",
".",
"string",
"[",
"self",
".",
"pos",
"+",
"offset",
":",
"]",
"else",
":",
"return... | A copy of the current position till the end of the source string. | [
"A",
"copy",
"of",
"the",
"current",
"position",
"till",
"the",
"end",
"of",
"the",
"source",
"string",
"."
] | dbb7d2fb285464fc43d85bc31f5af46192d301f6 | https://github.com/Nekroze/partpy/blob/dbb7d2fb285464fc43d85bc31f5af46192d301f6/partpy/sourcestring.py#L188-L193 |
41,392 | Nekroze/partpy | partpy/sourcestring.py | SourceString.get_current_line | def get_current_line(self):
"""Return a SourceLine of the current line."""
if not self.has_space():
return None
pos = self.pos - self.col
string = self.string
end = self.length
output = []
while pos < len(string) and string[pos] != '\n':
... | python | def get_current_line(self):
"""Return a SourceLine of the current line."""
if not self.has_space():
return None
pos = self.pos - self.col
string = self.string
end = self.length
output = []
while pos < len(string) and string[pos] != '\n':
... | [
"def",
"get_current_line",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"has_space",
"(",
")",
":",
"return",
"None",
"pos",
"=",
"self",
".",
"pos",
"-",
"self",
".",
"col",
"string",
"=",
"self",
".",
"string",
"end",
"=",
"self",
".",
"lengt... | Return a SourceLine of the current line. | [
"Return",
"a",
"SourceLine",
"of",
"the",
"current",
"line",
"."
] | dbb7d2fb285464fc43d85bc31f5af46192d301f6 | https://github.com/Nekroze/partpy/blob/dbb7d2fb285464fc43d85bc31f5af46192d301f6/partpy/sourcestring.py#L212-L233 |
41,393 | Nekroze/partpy | partpy/sourcestring.py | SourceString.get_lines | def get_lines(self, first, last):
"""Return SourceLines for lines between and including first & last."""
line = 1
linestring = []
linestrings = []
for char in self.string:
if line >= first and line <= last:
linestring.append(char)
if ch... | python | def get_lines(self, first, last):
"""Return SourceLines for lines between and including first & last."""
line = 1
linestring = []
linestrings = []
for char in self.string:
if line >= first and line <= last:
linestring.append(char)
if ch... | [
"def",
"get_lines",
"(",
"self",
",",
"first",
",",
"last",
")",
":",
"line",
"=",
"1",
"linestring",
"=",
"[",
"]",
"linestrings",
"=",
"[",
"]",
"for",
"char",
"in",
"self",
".",
"string",
":",
"if",
"line",
">=",
"first",
"and",
"line",
"<=",
... | Return SourceLines for lines between and including first & last. | [
"Return",
"SourceLines",
"for",
"lines",
"between",
"and",
"including",
"first",
"&",
"last",
"."
] | dbb7d2fb285464fc43d85bc31f5af46192d301f6 | https://github.com/Nekroze/partpy/blob/dbb7d2fb285464fc43d85bc31f5af46192d301f6/partpy/sourcestring.py#L235-L256 |
41,394 | Nekroze/partpy | partpy/sourcestring.py | SourceString.get_surrounding_lines | def get_surrounding_lines(self, past=1, future=1):
"""Return the current line and x,y previous and future lines.
Returns a list of SourceLine's.
"""
string = self.string
pos = self.pos - self.col
end = self.length
row = self.row
linesback = 0
whil... | python | def get_surrounding_lines(self, past=1, future=1):
"""Return the current line and x,y previous and future lines.
Returns a list of SourceLine's.
"""
string = self.string
pos = self.pos - self.col
end = self.length
row = self.row
linesback = 0
whil... | [
"def",
"get_surrounding_lines",
"(",
"self",
",",
"past",
"=",
"1",
",",
"future",
"=",
"1",
")",
":",
"string",
"=",
"self",
".",
"string",
"pos",
"=",
"self",
".",
"pos",
"-",
"self",
".",
"col",
"end",
"=",
"self",
".",
"length",
"row",
"=",
"... | Return the current line and x,y previous and future lines.
Returns a list of SourceLine's. | [
"Return",
"the",
"current",
"line",
"and",
"x",
"y",
"previous",
"and",
"future",
"lines",
".",
"Returns",
"a",
"list",
"of",
"SourceLine",
"s",
"."
] | dbb7d2fb285464fc43d85bc31f5af46192d301f6 | https://github.com/Nekroze/partpy/blob/dbb7d2fb285464fc43d85bc31f5af46192d301f6/partpy/sourcestring.py#L258-L294 |
41,395 | Nekroze/partpy | partpy/sourcestring.py | SourceString.get_all_lines | def get_all_lines(self):
"""Return all lines of the SourceString as a list of SourceLine's."""
output = []
line = []
lineno = 1
for char in self.string:
line.append(char)
if char == '\n':
output.append(SourceLine(''.join(line), lineno))
... | python | def get_all_lines(self):
"""Return all lines of the SourceString as a list of SourceLine's."""
output = []
line = []
lineno = 1
for char in self.string:
line.append(char)
if char == '\n':
output.append(SourceLine(''.join(line), lineno))
... | [
"def",
"get_all_lines",
"(",
"self",
")",
":",
"output",
"=",
"[",
"]",
"line",
"=",
"[",
"]",
"lineno",
"=",
"1",
"for",
"char",
"in",
"self",
".",
"string",
":",
"line",
".",
"append",
"(",
"char",
")",
"if",
"char",
"==",
"'\\n'",
":",
"output... | Return all lines of the SourceString as a list of SourceLine's. | [
"Return",
"all",
"lines",
"of",
"the",
"SourceString",
"as",
"a",
"list",
"of",
"SourceLine",
"s",
"."
] | dbb7d2fb285464fc43d85bc31f5af46192d301f6 | https://github.com/Nekroze/partpy/blob/dbb7d2fb285464fc43d85bc31f5af46192d301f6/partpy/sourcestring.py#L296-L310 |
41,396 | Nekroze/partpy | partpy/sourcestring.py | SourceString.match_string | def match_string(self, string, word=0, offset=0):
"""Returns 1 if string can be matches against SourceString's
current position.
If word is >= 1 then it will only match string followed by whitepsace.
"""
if word:
return self.get_string(offset) == string
retur... | python | def match_string(self, string, word=0, offset=0):
"""Returns 1 if string can be matches against SourceString's
current position.
If word is >= 1 then it will only match string followed by whitepsace.
"""
if word:
return self.get_string(offset) == string
retur... | [
"def",
"match_string",
"(",
"self",
",",
"string",
",",
"word",
"=",
"0",
",",
"offset",
"=",
"0",
")",
":",
"if",
"word",
":",
"return",
"self",
".",
"get_string",
"(",
"offset",
")",
"==",
"string",
"return",
"self",
".",
"get_length",
"(",
"len",
... | Returns 1 if string can be matches against SourceString's
current position.
If word is >= 1 then it will only match string followed by whitepsace. | [
"Returns",
"1",
"if",
"string",
"can",
"be",
"matches",
"against",
"SourceString",
"s",
"current",
"position",
"."
] | dbb7d2fb285464fc43d85bc31f5af46192d301f6 | https://github.com/Nekroze/partpy/blob/dbb7d2fb285464fc43d85bc31f5af46192d301f6/partpy/sourcestring.py#L312-L320 |
41,397 | Nekroze/partpy | partpy/sourcestring.py | SourceString.match_any_string | def match_any_string(self, strings, word=0, offset=0):
"""Attempts to match each string in strings in order.
Will return the string that matches or an empty string if no match.
If word arg >= 1 then only match if string is followed by a whitespace
which is much higher performance.
... | python | def match_any_string(self, strings, word=0, offset=0):
"""Attempts to match each string in strings in order.
Will return the string that matches or an empty string if no match.
If word arg >= 1 then only match if string is followed by a whitespace
which is much higher performance.
... | [
"def",
"match_any_string",
"(",
"self",
",",
"strings",
",",
"word",
"=",
"0",
",",
"offset",
"=",
"0",
")",
":",
"if",
"word",
":",
"current",
"=",
"self",
".",
"get_string",
"(",
"offset",
")",
"return",
"current",
"if",
"current",
"in",
"strings",
... | Attempts to match each string in strings in order.
Will return the string that matches or an empty string if no match.
If word arg >= 1 then only match if string is followed by a whitespace
which is much higher performance.
If word is 0 then you should sort the strings argument yoursel... | [
"Attempts",
"to",
"match",
"each",
"string",
"in",
"strings",
"in",
"order",
".",
"Will",
"return",
"the",
"string",
"that",
"matches",
"or",
"an",
"empty",
"string",
"if",
"no",
"match",
"."
] | dbb7d2fb285464fc43d85bc31f5af46192d301f6 | https://github.com/Nekroze/partpy/blob/dbb7d2fb285464fc43d85bc31f5af46192d301f6/partpy/sourcestring.py#L322-L345 |
41,398 | Nekroze/partpy | partpy/sourcestring.py | SourceString.match_any_char | def match_any_char(self, chars, offset=0):
"""Match and return the current SourceString char if its in chars."""
if not self.has_space(offset=offset):
return ''
current = self.string[self.pos + offset]
return current if current in chars else '' | python | def match_any_char(self, chars, offset=0):
"""Match and return the current SourceString char if its in chars."""
if not self.has_space(offset=offset):
return ''
current = self.string[self.pos + offset]
return current if current in chars else '' | [
"def",
"match_any_char",
"(",
"self",
",",
"chars",
",",
"offset",
"=",
"0",
")",
":",
"if",
"not",
"self",
".",
"has_space",
"(",
"offset",
"=",
"offset",
")",
":",
"return",
"''",
"current",
"=",
"self",
".",
"string",
"[",
"self",
".",
"pos",
"+... | Match and return the current SourceString char if its in chars. | [
"Match",
"and",
"return",
"the",
"current",
"SourceString",
"char",
"if",
"its",
"in",
"chars",
"."
] | dbb7d2fb285464fc43d85bc31f5af46192d301f6 | https://github.com/Nekroze/partpy/blob/dbb7d2fb285464fc43d85bc31f5af46192d301f6/partpy/sourcestring.py#L347-L352 |
41,399 | Nekroze/partpy | partpy/sourcestring.py | SourceString.match_function_pattern | def match_function_pattern(self, first, rest=None, least=1, offset=0):
"""Match each char sequentially from current SourceString position
until the pattern doesnt match and return all maches.
Integer argument least defines and minimum amount of chars that can
be matched.
This v... | python | def match_function_pattern(self, first, rest=None, least=1, offset=0):
"""Match each char sequentially from current SourceString position
until the pattern doesnt match and return all maches.
Integer argument least defines and minimum amount of chars that can
be matched.
This v... | [
"def",
"match_function_pattern",
"(",
"self",
",",
"first",
",",
"rest",
"=",
"None",
",",
"least",
"=",
"1",
",",
"offset",
"=",
"0",
")",
":",
"if",
"not",
"self",
".",
"has_space",
"(",
"offset",
"=",
"offset",
")",
":",
"return",
"''",
"firstchar... | Match each char sequentially from current SourceString position
until the pattern doesnt match and return all maches.
Integer argument least defines and minimum amount of chars that can
be matched.
This version takes functions instead of string patterns.
Each function must take... | [
"Match",
"each",
"char",
"sequentially",
"from",
"current",
"SourceString",
"position",
"until",
"the",
"pattern",
"doesnt",
"match",
"and",
"return",
"all",
"maches",
"."
] | dbb7d2fb285464fc43d85bc31f5af46192d301f6 | https://github.com/Nekroze/partpy/blob/dbb7d2fb285464fc43d85bc31f5af46192d301f6/partpy/sourcestring.py#L384-L416 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.