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 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
NoviceLive/intellicoder | intellicoder/msbuild/builders.py | Builder.make_objs | def make_objs(names, out_dir=''):
"""
Make object file names for cl.exe and link.exe.
"""
objs = [replace_ext(name, '.obj') for name in names]
if out_dir:
objs = [os.path.join(out_dir, obj) for obj in objs]
return objs | python | def make_objs(names, out_dir=''):
"""
Make object file names for cl.exe and link.exe.
"""
objs = [replace_ext(name, '.obj') for name in names]
if out_dir:
objs = [os.path.join(out_dir, obj) for obj in objs]
return objs | [
"def",
"make_objs",
"(",
"names",
",",
"out_dir",
"=",
"''",
")",
":",
"objs",
"=",
"[",
"replace_ext",
"(",
"name",
",",
"'.obj'",
")",
"for",
"name",
"in",
"names",
"]",
"if",
"out_dir",
":",
"objs",
"=",
"[",
"os",
".",
"path",
".",
"join",
"(... | Make object file names for cl.exe and link.exe. | [
"Make",
"object",
"file",
"names",
"for",
"cl",
".",
"exe",
"and",
"link",
".",
"exe",
"."
] | 6cac5ebfce65c370dbebe47756a1789b120ef982 | https://github.com/NoviceLive/intellicoder/blob/6cac5ebfce65c370dbebe47756a1789b120ef982/intellicoder/msbuild/builders.py#L129-L136 | train |
tgbugs/ontquery | ontquery/plugins/interlex_client.py | examples | def examples():
''' Examples of how to use. Default are that some functions are commented out in order
to not cause harm to existing metadata within the database.
'''
sci = InterLexClient(
api_key = os.environ.get('INTERLEX_API_KEY'),
base_url = 'https://beta.scicrunch.org/api/1/', #... | python | def examples():
''' Examples of how to use. Default are that some functions are commented out in order
to not cause harm to existing metadata within the database.
'''
sci = InterLexClient(
api_key = os.environ.get('INTERLEX_API_KEY'),
base_url = 'https://beta.scicrunch.org/api/1/', #... | [
"def",
"examples",
"(",
")",
":",
"sci",
"=",
"InterLexClient",
"(",
"api_key",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"'INTERLEX_API_KEY'",
")",
",",
"base_url",
"=",
"'https://beta.scicrunch.org/api/1/'",
",",
")",
"entity",
"=",
"{",
"'label'",
":",
... | Examples of how to use. Default are that some functions are commented out in order
to not cause harm to existing metadata within the database. | [
"Examples",
"of",
"how",
"to",
"use",
".",
"Default",
"are",
"that",
"some",
"functions",
"are",
"commented",
"out",
"in",
"order",
"to",
"not",
"cause",
"harm",
"to",
"existing",
"metadata",
"within",
"the",
"database",
"."
] | bcf4863cb2bf221afe2b093c5dc7da1377300041 | https://github.com/tgbugs/ontquery/blob/bcf4863cb2bf221afe2b093c5dc7da1377300041/ontquery/plugins/interlex_client.py#L778-L846 | train |
tgbugs/ontquery | ontquery/plugins/interlex_client.py | InterLexClient.process_response | def process_response(self, response: requests.models.Response) -> dict:
""" Checks for correct data response and status codes """
try:
output = response.json()
except json.JSONDecodeError: # Server is having a bad day and crashed.
raise self.BadResponseError(
... | python | def process_response(self, response: requests.models.Response) -> dict:
""" Checks for correct data response and status codes """
try:
output = response.json()
except json.JSONDecodeError: # Server is having a bad day and crashed.
raise self.BadResponseError(
... | [
"def",
"process_response",
"(",
"self",
",",
"response",
":",
"requests",
".",
"models",
".",
"Response",
")",
"->",
"dict",
":",
"try",
":",
"output",
"=",
"response",
".",
"json",
"(",
")",
"except",
"json",
".",
"JSONDecodeError",
":",
"raise",
"self"... | Checks for correct data response and status codes | [
"Checks",
"for",
"correct",
"data",
"response",
"and",
"status",
"codes"
] | bcf4863cb2bf221afe2b093c5dc7da1377300041 | https://github.com/tgbugs/ontquery/blob/bcf4863cb2bf221afe2b093c5dc7da1377300041/ontquery/plugins/interlex_client.py#L63-L79 | train |
tgbugs/ontquery | ontquery/plugins/interlex_client.py | InterLexClient.process_superclass | def process_superclass(self, entity: List[dict]) -> List[dict]:
""" Replaces ILX ID with superclass ID """
superclass = entity.pop('superclass')
label = entity['label']
if not superclass.get('ilx_id'):
raise self.SuperClassDoesNotExistError(
f'Superclass not g... | python | def process_superclass(self, entity: List[dict]) -> List[dict]:
""" Replaces ILX ID with superclass ID """
superclass = entity.pop('superclass')
label = entity['label']
if not superclass.get('ilx_id'):
raise self.SuperClassDoesNotExistError(
f'Superclass not g... | [
"def",
"process_superclass",
"(",
"self",
",",
"entity",
":",
"List",
"[",
"dict",
"]",
")",
"->",
"List",
"[",
"dict",
"]",
":",
"superclass",
"=",
"entity",
".",
"pop",
"(",
"'superclass'",
")",
"label",
"=",
"entity",
"[",
"'label'",
"]",
"if",
"n... | Replaces ILX ID with superclass ID | [
"Replaces",
"ILX",
"ID",
"with",
"superclass",
"ID"
] | bcf4863cb2bf221afe2b093c5dc7da1377300041 | https://github.com/tgbugs/ontquery/blob/bcf4863cb2bf221afe2b093c5dc7da1377300041/ontquery/plugins/interlex_client.py#L115-L128 | train |
tgbugs/ontquery | ontquery/plugins/interlex_client.py | InterLexClient.check_scicrunch_for_label | def check_scicrunch_for_label(self, label: str) -> dict:
""" Sees if label with your user ID already exists
There are can be multiples of the same label in interlex, but there should only be one
label with your user id. Therefore you can create labels if there already techniqually
exist... | python | def check_scicrunch_for_label(self, label: str) -> dict:
""" Sees if label with your user ID already exists
There are can be multiples of the same label in interlex, but there should only be one
label with your user id. Therefore you can create labels if there already techniqually
exist... | [
"def",
"check_scicrunch_for_label",
"(",
"self",
",",
"label",
":",
"str",
")",
"->",
"dict",
":",
"list_of_crude_matches",
"=",
"self",
".",
"crude_search_scicrunch_via_label",
"(",
"label",
")",
"for",
"crude_match",
"in",
"list_of_crude_matches",
":",
"if",
"cr... | Sees if label with your user ID already exists
There are can be multiples of the same label in interlex, but there should only be one
label with your user id. Therefore you can create labels if there already techniqually
exist, but not if you are the one to create it. | [
"Sees",
"if",
"label",
"with",
"your",
"user",
"ID",
"already",
"exists"
] | bcf4863cb2bf221afe2b093c5dc7da1377300041 | https://github.com/tgbugs/ontquery/blob/bcf4863cb2bf221afe2b093c5dc7da1377300041/ontquery/plugins/interlex_client.py#L162-L180 | train |
tgbugs/ontquery | ontquery/plugins/interlex_client.py | InterLexClient.add_raw_entity | def add_raw_entity(self, entity: dict) -> dict:
""" Adds entity if it does not already exist under your user ID.
Need to provide a list of dictionaries that have at least the key/values
for label and type. If given a key, the values provided must be in the
format shown in or... | python | def add_raw_entity(self, entity: dict) -> dict:
""" Adds entity if it does not already exist under your user ID.
Need to provide a list of dictionaries that have at least the key/values
for label and type. If given a key, the values provided must be in the
format shown in or... | [
"def",
"add_raw_entity",
"(",
"self",
",",
"entity",
":",
"dict",
")",
"->",
"dict",
":",
"needed_in_entity",
"=",
"set",
"(",
"[",
"'label'",
",",
"'type'",
",",
"]",
")",
"options_in_entity",
"=",
"set",
"(",
"[",
"'label'",
",",
"'type'",
",",
"'def... | Adds entity if it does not already exist under your user ID.
Need to provide a list of dictionaries that have at least the key/values
for label and type. If given a key, the values provided must be in the
format shown in order for the server to except them. You can input
... | [
"Adds",
"entity",
"if",
"it",
"does",
"not",
"already",
"exist",
"under",
"your",
"user",
"ID",
"."
] | bcf4863cb2bf221afe2b093c5dc7da1377300041 | https://github.com/tgbugs/ontquery/blob/bcf4863cb2bf221afe2b093c5dc7da1377300041/ontquery/plugins/interlex_client.py#L266-L401 | train |
tgbugs/ontquery | ontquery/plugins/interlex_client.py | InterLexClient.add_annotation | def add_annotation(
self,
term_ilx_id: str,
annotation_type_ilx_id: str,
annotation_value: str) -> dict:
""" Adding an annotation value to a prexisting entity
An annotation exists as 3 different parts:
1. entity with type term, cde, fde, or pde
2.... | python | def add_annotation(
self,
term_ilx_id: str,
annotation_type_ilx_id: str,
annotation_value: str) -> dict:
""" Adding an annotation value to a prexisting entity
An annotation exists as 3 different parts:
1. entity with type term, cde, fde, or pde
2.... | [
"def",
"add_annotation",
"(",
"self",
",",
"term_ilx_id",
":",
"str",
",",
"annotation_type_ilx_id",
":",
"str",
",",
"annotation_value",
":",
"str",
")",
"->",
"dict",
":",
"url",
"=",
"self",
".",
"base_url",
"+",
"'term/add-annotation'",
"term_data",
"=",
... | Adding an annotation value to a prexisting entity
An annotation exists as 3 different parts:
1. entity with type term, cde, fde, or pde
2. entity with type annotation
3. string value of the annotation
Example:
annotation = {
'term_ilx_id'... | [
"Adding",
"an",
"annotation",
"value",
"to",
"a",
"prexisting",
"entity"
] | bcf4863cb2bf221afe2b093c5dc7da1377300041 | https://github.com/tgbugs/ontquery/blob/bcf4863cb2bf221afe2b093c5dc7da1377300041/ontquery/plugins/interlex_client.py#L527-L589 | train |
tgbugs/ontquery | ontquery/plugins/interlex_client.py | InterLexClient.delete_annotation | def delete_annotation(
self,
term_ilx_id: str,
annotation_type_ilx_id: str,
annotation_value: str) -> dict:
""" If annotation doesnt exist, add it
"""
term_data = self.get_entity(term_ilx_id)
if not term_data['id']:
exit(
'term... | python | def delete_annotation(
self,
term_ilx_id: str,
annotation_type_ilx_id: str,
annotation_value: str) -> dict:
""" If annotation doesnt exist, add it
"""
term_data = self.get_entity(term_ilx_id)
if not term_data['id']:
exit(
'term... | [
"def",
"delete_annotation",
"(",
"self",
",",
"term_ilx_id",
":",
"str",
",",
"annotation_type_ilx_id",
":",
"str",
",",
"annotation_value",
":",
"str",
")",
"->",
"dict",
":",
"term_data",
"=",
"self",
".",
"get_entity",
"(",
"term_ilx_id",
")",
"if",
"not"... | If annotation doesnt exist, add it | [
"If",
"annotation",
"doesnt",
"exist",
"add",
"it"
] | bcf4863cb2bf221afe2b093c5dc7da1377300041 | https://github.com/tgbugs/ontquery/blob/bcf4863cb2bf221afe2b093c5dc7da1377300041/ontquery/plugins/interlex_client.py#L591-L642 | train |
lowandrew/OLCTools | databasesetup/rest_auth_class.py | REST.main | def main(self):
"""
Run the appropriate methods in the correct order
"""
self.secret_finder()
self.parse_access_token()
self.get_session_token()
self.parse_session_token()
self.get_route()
self.download_profile()
self.find_loci()
se... | python | def main(self):
"""
Run the appropriate methods in the correct order
"""
self.secret_finder()
self.parse_access_token()
self.get_session_token()
self.parse_session_token()
self.get_route()
self.download_profile()
self.find_loci()
se... | [
"def",
"main",
"(",
"self",
")",
":",
"self",
".",
"secret_finder",
"(",
")",
"self",
".",
"parse_access_token",
"(",
")",
"self",
".",
"get_session_token",
"(",
")",
"self",
".",
"parse_session_token",
"(",
")",
"self",
".",
"get_route",
"(",
")",
"self... | Run the appropriate methods in the correct order | [
"Run",
"the",
"appropriate",
"methods",
"in",
"the",
"correct",
"order"
] | 88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a | https://github.com/lowandrew/OLCTools/blob/88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a/databasesetup/rest_auth_class.py#L37-L48 | train |
lowandrew/OLCTools | databasesetup/rest_auth_class.py | REST.secret_finder | def secret_finder(self):
"""
Parses the supplied secret.txt file for the consumer key and secrets
"""
secretlist = list()
if os.path.isfile(self.secret_file):
# Open the file, and put the contents into a list
with open(self.secret_file, 'r') as secret:
... | python | def secret_finder(self):
"""
Parses the supplied secret.txt file for the consumer key and secrets
"""
secretlist = list()
if os.path.isfile(self.secret_file):
# Open the file, and put the contents into a list
with open(self.secret_file, 'r') as secret:
... | [
"def",
"secret_finder",
"(",
"self",
")",
":",
"secretlist",
"=",
"list",
"(",
")",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"self",
".",
"secret_file",
")",
":",
"with",
"open",
"(",
"self",
".",
"secret_file",
",",
"'r'",
")",
"as",
"secret",
... | Parses the supplied secret.txt file for the consumer key and secrets | [
"Parses",
"the",
"supplied",
"secret",
".",
"txt",
"file",
"for",
"the",
"consumer",
"key",
"and",
"secrets"
] | 88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a | https://github.com/lowandrew/OLCTools/blob/88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a/databasesetup/rest_auth_class.py#L50-L68 | train |
lowandrew/OLCTools | databasesetup/rest_auth_class.py | REST.parse_access_token | def parse_access_token(self):
"""
Extract the secret and token values from the access_token file
"""
access_file = os.path.join(self.file_path, 'access_token')
# Ensure that the access_token file exists
if os.path.isfile(access_file):
# Initialise a list to st... | python | def parse_access_token(self):
"""
Extract the secret and token values from the access_token file
"""
access_file = os.path.join(self.file_path, 'access_token')
# Ensure that the access_token file exists
if os.path.isfile(access_file):
# Initialise a list to st... | [
"def",
"parse_access_token",
"(",
"self",
")",
":",
"access_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"file_path",
",",
"'access_token'",
")",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"access_file",
")",
":",
"access_list",
"=",
... | Extract the secret and token values from the access_token file | [
"Extract",
"the",
"secret",
"and",
"token",
"values",
"from",
"the",
"access_token",
"file"
] | 88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a | https://github.com/lowandrew/OLCTools/blob/88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a/databasesetup/rest_auth_class.py#L70-L89 | train |
lowandrew/OLCTools | databasesetup/rest_auth_class.py | REST.get_request_token | def get_request_token(self):
"""
Obtain a request token
"""
print('Obtaining request token')
try:
os.remove(os.path.join(self.file_path, 'request_token'))
except FileNotFoundError:
pass
# Create a new session
session = OAuth1Session... | python | def get_request_token(self):
"""
Obtain a request token
"""
print('Obtaining request token')
try:
os.remove(os.path.join(self.file_path, 'request_token'))
except FileNotFoundError:
pass
# Create a new session
session = OAuth1Session... | [
"def",
"get_request_token",
"(",
"self",
")",
":",
"print",
"(",
"'Obtaining request token'",
")",
"try",
":",
"os",
".",
"remove",
"(",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"file_path",
",",
"'request_token'",
")",
")",
"except",
"FileNotFoun... | Obtain a request token | [
"Obtain",
"a",
"request",
"token"
] | 88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a | https://github.com/lowandrew/OLCTools/blob/88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a/databasesetup/rest_auth_class.py#L119-L141 | train |
lowandrew/OLCTools | databasesetup/rest_auth_class.py | REST.get_session_token | def get_session_token(self):
"""
Use the accession token to request a new session token
"""
# self.logging.info('Getting session token')
# Rather than testing any previous session tokens to see if they are still valid, simply delete old tokens in
# preparation of the crea... | python | def get_session_token(self):
"""
Use the accession token to request a new session token
"""
# self.logging.info('Getting session token')
# Rather than testing any previous session tokens to see if they are still valid, simply delete old tokens in
# preparation of the crea... | [
"def",
"get_session_token",
"(",
"self",
")",
":",
"try",
":",
"os",
".",
"remove",
"(",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"file_path",
",",
"'session_token'",
")",
")",
"except",
"FileNotFoundError",
":",
"pass",
"session_request",
"=",
... | Use the accession token to request a new session token | [
"Use",
"the",
"accession",
"token",
"to",
"request",
"a",
"new",
"session",
"token"
] | 88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a | https://github.com/lowandrew/OLCTools/blob/88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a/databasesetup/rest_auth_class.py#L143-L171 | train |
lowandrew/OLCTools | databasesetup/rest_auth_class.py | REST.parse_session_token | def parse_session_token(self):
"""
Extract the session secret and token strings from the session token file
"""
session_file = os.path.join(self.file_path, 'session_token')
# Only try to extract the strings if the file exists
if os.path.isfile(session_file):
#... | python | def parse_session_token(self):
"""
Extract the session secret and token strings from the session token file
"""
session_file = os.path.join(self.file_path, 'session_token')
# Only try to extract the strings if the file exists
if os.path.isfile(session_file):
#... | [
"def",
"parse_session_token",
"(",
"self",
")",
":",
"session_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"file_path",
",",
"'session_token'",
")",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"session_file",
")",
":",
"session_list",
"... | Extract the session secret and token strings from the session token file | [
"Extract",
"the",
"session",
"secret",
"and",
"token",
"strings",
"from",
"the",
"session",
"token",
"file"
] | 88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a | https://github.com/lowandrew/OLCTools/blob/88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a/databasesetup/rest_auth_class.py#L185-L202 | train |
lowandrew/OLCTools | databasesetup/rest_auth_class.py | REST.get_route | def get_route(self):
"""
Creates a session to find the URL for the loci and schemes
"""
# Create a new session
session = OAuth1Session(self.consumer_key,
self.consumer_secret,
access_token=self.session_token,
... | python | def get_route(self):
"""
Creates a session to find the URL for the loci and schemes
"""
# Create a new session
session = OAuth1Session(self.consumer_key,
self.consumer_secret,
access_token=self.session_token,
... | [
"def",
"get_route",
"(",
"self",
")",
":",
"session",
"=",
"OAuth1Session",
"(",
"self",
".",
"consumer_key",
",",
"self",
".",
"consumer_secret",
",",
"access_token",
"=",
"self",
".",
"session_token",
",",
"access_token_secret",
"=",
"self",
".",
"session_se... | Creates a session to find the URL for the loci and schemes | [
"Creates",
"a",
"session",
"to",
"find",
"the",
"URL",
"for",
"the",
"loci",
"and",
"schemes"
] | 88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a | https://github.com/lowandrew/OLCTools/blob/88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a/databasesetup/rest_auth_class.py#L204-L222 | train |
lowandrew/OLCTools | databasesetup/rest_auth_class.py | REST.download_profile | def download_profile(self):
"""
Download the profile from the database
"""
# Set the name of the profile file
profile_file = os.path.join(self.output_path, 'profile.txt')
size = 0
# Ensure that the file exists, and that it is not too small; likely indicating a fai... | python | def download_profile(self):
"""
Download the profile from the database
"""
# Set the name of the profile file
profile_file = os.path.join(self.output_path, 'profile.txt')
size = 0
# Ensure that the file exists, and that it is not too small; likely indicating a fai... | [
"def",
"download_profile",
"(",
"self",
")",
":",
"profile_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"output_path",
",",
"'profile.txt'",
")",
"size",
"=",
"0",
"try",
":",
"stats",
"=",
"os",
".",
"stat",
"(",
"profile_file",
")",
... | Download the profile from the database | [
"Download",
"the",
"profile",
"from",
"the",
"database"
] | 88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a | https://github.com/lowandrew/OLCTools/blob/88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a/databasesetup/rest_auth_class.py#L224-L254 | train |
lowandrew/OLCTools | databasesetup/rest_auth_class.py | REST.find_loci | def find_loci(self):
"""
Finds the URLs for all allele files
"""
session = OAuth1Session(self.consumer_key,
self.consumer_secret,
access_token=self.session_token,
access_token_secret=self.sess... | python | def find_loci(self):
"""
Finds the URLs for all allele files
"""
session = OAuth1Session(self.consumer_key,
self.consumer_secret,
access_token=self.session_token,
access_token_secret=self.sess... | [
"def",
"find_loci",
"(",
"self",
")",
":",
"session",
"=",
"OAuth1Session",
"(",
"self",
".",
"consumer_key",
",",
"self",
".",
"consumer_secret",
",",
"access_token",
"=",
"self",
".",
"session_token",
",",
"access_token_secret",
"=",
"self",
".",
"session_se... | Finds the URLs for all allele files | [
"Finds",
"the",
"URLs",
"for",
"all",
"allele",
"files"
] | 88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a | https://github.com/lowandrew/OLCTools/blob/88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a/databasesetup/rest_auth_class.py#L256-L274 | train |
lowandrew/OLCTools | databasesetup/rest_auth_class.py | REST.download_loci | def download_loci(self):
"""
Uses a multi-threaded approach to download allele files
"""
# Setup the multiprocessing pool.
pool = multiprocessing.Pool(processes=self.threads)
# Map the list of loci URLs to the download method
pool.map(self.download_threads, self.l... | python | def download_loci(self):
"""
Uses a multi-threaded approach to download allele files
"""
# Setup the multiprocessing pool.
pool = multiprocessing.Pool(processes=self.threads)
# Map the list of loci URLs to the download method
pool.map(self.download_threads, self.l... | [
"def",
"download_loci",
"(",
"self",
")",
":",
"pool",
"=",
"multiprocessing",
".",
"Pool",
"(",
"processes",
"=",
"self",
".",
"threads",
")",
"pool",
".",
"map",
"(",
"self",
".",
"download_threads",
",",
"self",
".",
"loci_url",
")",
"pool",
".",
"c... | Uses a multi-threaded approach to download allele files | [
"Uses",
"a",
"multi",
"-",
"threaded",
"approach",
"to",
"download",
"allele",
"files"
] | 88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a | https://github.com/lowandrew/OLCTools/blob/88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a/databasesetup/rest_auth_class.py#L276-L285 | train |
lowandrew/OLCTools | databasesetup/rest_auth_class.py | REST.download_threads | def download_threads(self, url):
"""
Download the allele files
"""
# Set the name of the allele file - split the gene name from the URL
output_file = os.path.join(self.output_path, '{}.tfa'.format(os.path.split(url)[-1]))
# Check to see whether the file already exists, an... | python | def download_threads(self, url):
"""
Download the allele files
"""
# Set the name of the allele file - split the gene name from the URL
output_file = os.path.join(self.output_path, '{}.tfa'.format(os.path.split(url)[-1]))
# Check to see whether the file already exists, an... | [
"def",
"download_threads",
"(",
"self",
",",
"url",
")",
":",
"output_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"output_path",
",",
"'{}.tfa'",
".",
"format",
"(",
"os",
".",
"path",
".",
"split",
"(",
"url",
")",
"[",
"-",
"1",... | Download the allele files | [
"Download",
"the",
"allele",
"files"
] | 88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a | https://github.com/lowandrew/OLCTools/blob/88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a/databasesetup/rest_auth_class.py#L287-L316 | train |
by46/simplekit | simplekit/objson/dolphin2.py | dumps | def dumps(obj, *args, **kwargs):
"""Serialize a object to string
Basic Usage:
>>> import simplekit.objson
>>> obj = {'name':'wendy'}
>>> print simplekit.objson.dumps(obj)
:param obj: a object which need to dump
:param args: Optional arguments that :func:`json.dumps` takes.
:param kwa... | python | def dumps(obj, *args, **kwargs):
"""Serialize a object to string
Basic Usage:
>>> import simplekit.objson
>>> obj = {'name':'wendy'}
>>> print simplekit.objson.dumps(obj)
:param obj: a object which need to dump
:param args: Optional arguments that :func:`json.dumps` takes.
:param kwa... | [
"def",
"dumps",
"(",
"obj",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"kwargs",
"[",
"'default'",
"]",
"=",
"object2dict",
"return",
"json",
".",
"dumps",
"(",
"obj",
",",
"*",
"args",
",",
"**",
"kwargs",
")"
] | Serialize a object to string
Basic Usage:
>>> import simplekit.objson
>>> obj = {'name':'wendy'}
>>> print simplekit.objson.dumps(obj)
:param obj: a object which need to dump
:param args: Optional arguments that :func:`json.dumps` takes.
:param kwargs: Keys arguments that :py:func:`json.... | [
"Serialize",
"a",
"object",
"to",
"string"
] | 33f3ce6de33accc185e1057f096af41859db5976 | https://github.com/by46/simplekit/blob/33f3ce6de33accc185e1057f096af41859db5976/simplekit/objson/dolphin2.py#L78-L95 | train |
by46/simplekit | simplekit/objson/dolphin2.py | dump | def dump(obj, fp, *args, **kwargs):
"""Serialize a object to a file object.
Basic Usage:
>>> import simplekit.objson
>>> from cStringIO import StringIO
>>> obj = {'name': 'wendy'}
>>> io = StringIO()
>>> simplekit.objson.dump(obj, io)
>>> print io.getvalue()
:param obj: a object w... | python | def dump(obj, fp, *args, **kwargs):
"""Serialize a object to a file object.
Basic Usage:
>>> import simplekit.objson
>>> from cStringIO import StringIO
>>> obj = {'name': 'wendy'}
>>> io = StringIO()
>>> simplekit.objson.dump(obj, io)
>>> print io.getvalue()
:param obj: a object w... | [
"def",
"dump",
"(",
"obj",
",",
"fp",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"kwargs",
"[",
"'default'",
"]",
"=",
"object2dict",
"json",
".",
"dump",
"(",
"obj",
",",
"fp",
",",
"*",
"args",
",",
"**",
"kwargs",
")"
] | Serialize a object to a file object.
Basic Usage:
>>> import simplekit.objson
>>> from cStringIO import StringIO
>>> obj = {'name': 'wendy'}
>>> io = StringIO()
>>> simplekit.objson.dump(obj, io)
>>> print io.getvalue()
:param obj: a object which need to dump
:param fp: a instance... | [
"Serialize",
"a",
"object",
"to",
"a",
"file",
"object",
"."
] | 33f3ce6de33accc185e1057f096af41859db5976 | https://github.com/by46/simplekit/blob/33f3ce6de33accc185e1057f096af41859db5976/simplekit/objson/dolphin2.py#L98-L118 | train |
jayme-github/steam_idle | steam_idle/idle.py | calc_delay | def calc_delay(remainingDrops):
''' Calculate the idle delay
Minimum play time for cards to drop is ~20min again. Except for accounts
that requested a refund?
Re-check every 15 mintes if there are more than 1 card drops remaining.
If only one drop remains, check every 5 minutes
... | python | def calc_delay(remainingDrops):
''' Calculate the idle delay
Minimum play time for cards to drop is ~20min again. Except for accounts
that requested a refund?
Re-check every 15 mintes if there are more than 1 card drops remaining.
If only one drop remains, check every 5 minutes
... | [
"def",
"calc_delay",
"(",
"remainingDrops",
")",
":",
"global",
"sameDelay",
",",
"lastDelay",
"if",
"remainingDrops",
">",
"1",
":",
"lastDelay",
"=",
"5",
"sameDelay",
"=",
"0",
"if",
"remainingDrops",
">",
"2",
":",
"return",
"15",
"*",
"60",
"elif",
... | Calculate the idle delay
Minimum play time for cards to drop is ~20min again. Except for accounts
that requested a refund?
Re-check every 15 mintes if there are more than 1 card drops remaining.
If only one drop remains, check every 5 minutes | [
"Calculate",
"the",
"idle",
"delay",
"Minimum",
"play",
"time",
"for",
"cards",
"to",
"drop",
"is",
"~20min",
"again",
".",
"Except",
"for",
"accounts",
"that",
"requested",
"a",
"refund?"
] | 4f9b887fd6c3aea3baa9087f88ee739efcc150cc | https://github.com/jayme-github/steam_idle/blob/4f9b887fd6c3aea3baa9087f88ee739efcc150cc/steam_idle/idle.py#L53-L79 | train |
lowandrew/OLCTools | spadespipeline/fastqCreator.py | CreateFastq.configfilepopulator | def configfilepopulator(self):
"""Populates an unpopulated config.xml file with run-specific values and creates
the file in the appropriate location"""
# Set the number of cycles for each read and index using the number of reads specified in the sample sheet
self.forwardlength = self.met... | python | def configfilepopulator(self):
"""Populates an unpopulated config.xml file with run-specific values and creates
the file in the appropriate location"""
# Set the number of cycles for each read and index using the number of reads specified in the sample sheet
self.forwardlength = self.met... | [
"def",
"configfilepopulator",
"(",
"self",
")",
":",
"self",
".",
"forwardlength",
"=",
"self",
".",
"metadata",
".",
"header",
".",
"forwardlength",
"self",
".",
"reverselength",
"=",
"self",
".",
"metadata",
".",
"header",
".",
"reverselength",
"cycles",
"... | Populates an unpopulated config.xml file with run-specific values and creates
the file in the appropriate location | [
"Populates",
"an",
"unpopulated",
"config",
".",
"xml",
"file",
"with",
"run",
"-",
"specific",
"values",
"and",
"creates",
"the",
"file",
"in",
"the",
"appropriate",
"location"
] | 88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a | https://github.com/lowandrew/OLCTools/blob/88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a/spadespipeline/fastqCreator.py#L138-L194 | train |
yamcs/yamcs-python | yamcs-client/examples/change_alarms.py | subscribe_param | def subscribe_param():
"""Print value of parameter"""
def print_data(data):
for parameter in data.parameters:
print(parameter)
processor.create_parameter_subscription('/YSS/SIMULATOR/BatteryVoltage2',
on_data=print_data) | python | def subscribe_param():
"""Print value of parameter"""
def print_data(data):
for parameter in data.parameters:
print(parameter)
processor.create_parameter_subscription('/YSS/SIMULATOR/BatteryVoltage2',
on_data=print_data) | [
"def",
"subscribe_param",
"(",
")",
":",
"def",
"print_data",
"(",
"data",
")",
":",
"for",
"parameter",
"in",
"data",
".",
"parameters",
":",
"print",
"(",
"parameter",
")",
"processor",
".",
"create_parameter_subscription",
"(",
"'/YSS/SIMULATOR/BatteryVoltage2'... | Print value of parameter | [
"Print",
"value",
"of",
"parameter"
] | 1082fee8a299010cc44416bbb7518fac0ef08b48 | https://github.com/yamcs/yamcs-python/blob/1082fee8a299010cc44416bbb7518fac0ef08b48/yamcs-client/examples/change_alarms.py#L7-L14 | train |
wanshot/holiday | holiday/core.py | Holiday._check_holiday_structure | def _check_holiday_structure(self, times):
""" To check the structure of the HolidayClass
:param list times: years or months or days or number week
:rtype: None or Exception
:return: in the case of exception returns the exception
"""
if not isinstance(times, list):
... | python | def _check_holiday_structure(self, times):
""" To check the structure of the HolidayClass
:param list times: years or months or days or number week
:rtype: None or Exception
:return: in the case of exception returns the exception
"""
if not isinstance(times, list):
... | [
"def",
"_check_holiday_structure",
"(",
"self",
",",
"times",
")",
":",
"if",
"not",
"isinstance",
"(",
"times",
",",
"list",
")",
":",
"raise",
"TypeError",
"(",
"\"an list is required\"",
")",
"for",
"time",
"in",
"times",
":",
"if",
"not",
"isinstance",
... | To check the structure of the HolidayClass
:param list times: years or months or days or number week
:rtype: None or Exception
:return: in the case of exception returns the exception | [
"To",
"check",
"the",
"structure",
"of",
"the",
"HolidayClass"
] | e08681c237d684aa05ba2f98b3baa388dab9eea6 | https://github.com/wanshot/holiday/blob/e08681c237d684aa05ba2f98b3baa388dab9eea6/holiday/core.py#L75-L96 | train |
wanshot/holiday | holiday/core.py | Holiday._check_time_format | def _check_time_format(self, labels, values):
""" To check the format of the times
:param list labels: years or months or days or number week
:param list values: number or the asterisk in the list
:rtype: None or Exception
:raises PeriodRangeError: outside the scope of the perio... | python | def _check_time_format(self, labels, values):
""" To check the format of the times
:param list labels: years or months or days or number week
:param list values: number or the asterisk in the list
:rtype: None or Exception
:raises PeriodRangeError: outside the scope of the perio... | [
"def",
"_check_time_format",
"(",
"self",
",",
"labels",
",",
"values",
")",
":",
"for",
"label",
",",
"value",
"in",
"zip",
"(",
"labels",
",",
"values",
")",
":",
"if",
"value",
"==",
"\"*\"",
":",
"continue",
"if",
"label",
"==",
"\"day_of_week\"",
... | To check the format of the times
:param list labels: years or months or days or number week
:param list values: number or the asterisk in the list
:rtype: None or Exception
:raises PeriodRangeError: outside the scope of the period
:raises ParseError: not parse the day of the wee... | [
"To",
"check",
"the",
"format",
"of",
"the",
"times"
] | e08681c237d684aa05ba2f98b3baa388dab9eea6 | https://github.com/wanshot/holiday/blob/e08681c237d684aa05ba2f98b3baa388dab9eea6/holiday/core.py#L98-L130 | train |
wanshot/holiday | holiday/core.py | Holiday.is_holiday | def is_holiday(self, date):
""" Whether holiday judges
:param datetime date: datetime.date object
:rtype: bool
"""
time = [
date.year,
date.month,
date.day,
date.isoweekday(),
_extract_week_number(date)
]
... | python | def is_holiday(self, date):
""" Whether holiday judges
:param datetime date: datetime.date object
:rtype: bool
"""
time = [
date.year,
date.month,
date.day,
date.isoweekday(),
_extract_week_number(date)
]
... | [
"def",
"is_holiday",
"(",
"self",
",",
"date",
")",
":",
"time",
"=",
"[",
"date",
".",
"year",
",",
"date",
".",
"month",
",",
"date",
".",
"day",
",",
"date",
".",
"isoweekday",
"(",
")",
",",
"_extract_week_number",
"(",
"date",
")",
"]",
"targe... | Whether holiday judges
:param datetime date: datetime.date object
:rtype: bool | [
"Whether",
"holiday",
"judges"
] | e08681c237d684aa05ba2f98b3baa388dab9eea6 | https://github.com/wanshot/holiday/blob/e08681c237d684aa05ba2f98b3baa388dab9eea6/holiday/core.py#L132-L156 | train |
kevinconway/venvctrl | venvctrl/venv/create.py | CreateMixin.create | def create(self, python=None, system_site=False, always_copy=False):
"""Create a new virtual environment.
Args:
python (str): The name or path of a python interpreter to use while
creating the virtual environment.
system_site (bool): Whether or not use use the sy... | python | def create(self, python=None, system_site=False, always_copy=False):
"""Create a new virtual environment.
Args:
python (str): The name or path of a python interpreter to use while
creating the virtual environment.
system_site (bool): Whether or not use use the sy... | [
"def",
"create",
"(",
"self",
",",
"python",
"=",
"None",
",",
"system_site",
"=",
"False",
",",
"always_copy",
"=",
"False",
")",
":",
"command",
"=",
"'virtualenv'",
"if",
"python",
":",
"command",
"=",
"'{0} --python={1}'",
".",
"format",
"(",
"command"... | Create a new virtual environment.
Args:
python (str): The name or path of a python interpreter to use while
creating the virtual environment.
system_site (bool): Whether or not use use the system site packages
within the virtual environment. Default is Fa... | [
"Create",
"a",
"new",
"virtual",
"environment",
"."
] | 36d4e0e4d5ebced6385a6ade1198f4769ff2df41 | https://github.com/kevinconway/venvctrl/blob/36d4e0e4d5ebced6385a6ade1198f4769ff2df41/venvctrl/venv/create.py#L16-L41 | train |
lowandrew/OLCTools | spadespipeline/vtyper.py | Vtyper.epcrparse | def epcrparse(self):
"""
Parse the ePCR text file outputs
"""
logging.info('Parsing ePCR results')
for sample in self.metadata:
if sample.general.bestassemblyfile != 'NA':
if 'stx' in sample.general.datastore:
# Initialise count - t... | python | def epcrparse(self):
"""
Parse the ePCR text file outputs
"""
logging.info('Parsing ePCR results')
for sample in self.metadata:
if sample.general.bestassemblyfile != 'NA':
if 'stx' in sample.general.datastore:
# Initialise count - t... | [
"def",
"epcrparse",
"(",
"self",
")",
":",
"logging",
".",
"info",
"(",
"'Parsing ePCR results'",
")",
"for",
"sample",
"in",
"self",
".",
"metadata",
":",
"if",
"sample",
".",
"general",
".",
"bestassemblyfile",
"!=",
"'NA'",
":",
"if",
"'stx'",
"in",
"... | Parse the ePCR text file outputs | [
"Parse",
"the",
"ePCR",
"text",
"file",
"outputs"
] | 88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a | https://github.com/lowandrew/OLCTools/blob/88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a/spadespipeline/vtyper.py#L96-L131 | train |
tgbugs/ontquery | ontquery/terms.py | OntCuries.populate | def populate(cls, graph):
""" populate an rdflib graph with these curies """
[graph.bind(k, v) for k, v in cls._dict.items()] | python | def populate(cls, graph):
""" populate an rdflib graph with these curies """
[graph.bind(k, v) for k, v in cls._dict.items()] | [
"def",
"populate",
"(",
"cls",
",",
"graph",
")",
":",
"[",
"graph",
".",
"bind",
"(",
"k",
",",
"v",
")",
"for",
"k",
",",
"v",
"in",
"cls",
".",
"_dict",
".",
"items",
"(",
")",
"]"
] | populate an rdflib graph with these curies | [
"populate",
"an",
"rdflib",
"graph",
"with",
"these",
"curies"
] | bcf4863cb2bf221afe2b093c5dc7da1377300041 | https://github.com/tgbugs/ontquery/blob/bcf4863cb2bf221afe2b093c5dc7da1377300041/ontquery/terms.py#L51-L53 | train |
mediawiki-utilities/python-mwoauth | mwoauth/flask.py | authorized | def authorized(route):
"""
Wrap a flask route. Ensure that the user has authorized via OAuth or
redirect the user to the authorization endpoint with a delayed redirect
back to the originating endpoint.
"""
@wraps(route)
def authorized_route(*args, **kwargs):
if 'mwoauth_access_token'... | python | def authorized(route):
"""
Wrap a flask route. Ensure that the user has authorized via OAuth or
redirect the user to the authorization endpoint with a delayed redirect
back to the originating endpoint.
"""
@wraps(route)
def authorized_route(*args, **kwargs):
if 'mwoauth_access_token'... | [
"def",
"authorized",
"(",
"route",
")",
":",
"@",
"wraps",
"(",
"route",
")",
"def",
"authorized_route",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"if",
"'mwoauth_access_token'",
"in",
"flask",
".",
"session",
":",
"return",
"route",
"(",
"*",
"... | Wrap a flask route. Ensure that the user has authorized via OAuth or
redirect the user to the authorization endpoint with a delayed redirect
back to the originating endpoint. | [
"Wrap",
"a",
"flask",
"route",
".",
"Ensure",
"that",
"the",
"user",
"has",
"authorized",
"via",
"OAuth",
"or",
"redirect",
"the",
"user",
"to",
"the",
"authorization",
"endpoint",
"with",
"a",
"delayed",
"redirect",
"back",
"to",
"the",
"originating",
"endp... | cd6990753ec3d59b7cfd96a76459f71ef4790cd3 | https://github.com/mediawiki-utilities/python-mwoauth/blob/cd6990753ec3d59b7cfd96a76459f71ef4790cd3/mwoauth/flask.py#L237-L252 | train |
sirfoga/pyhal | hal/maths/primes.py | blum_blum_shub | def blum_blum_shub(seed, amount, prime0, prime1):
"""Creates pseudo-number generator
:param seed: seeder
:param amount: amount of number to generate
:param prime0: one prime number
:param prime1: the second prime number
:return: pseudo-number generator
"""
if amount == 0:
return... | python | def blum_blum_shub(seed, amount, prime0, prime1):
"""Creates pseudo-number generator
:param seed: seeder
:param amount: amount of number to generate
:param prime0: one prime number
:param prime1: the second prime number
:return: pseudo-number generator
"""
if amount == 0:
return... | [
"def",
"blum_blum_shub",
"(",
"seed",
",",
"amount",
",",
"prime0",
",",
"prime1",
")",
":",
"if",
"amount",
"==",
"0",
":",
"return",
"[",
"]",
"assert",
"(",
"prime0",
"%",
"4",
"==",
"3",
"and",
"prime1",
"%",
"4",
"==",
"3",
")",
"mod",
"=",
... | Creates pseudo-number generator
:param seed: seeder
:param amount: amount of number to generate
:param prime0: one prime number
:param prime1: the second prime number
:return: pseudo-number generator | [
"Creates",
"pseudo",
"-",
"number",
"generator"
] | 4394d8a1f7e45bea28a255ec390f4962ee64d33a | https://github.com/sirfoga/pyhal/blob/4394d8a1f7e45bea28a255ec390f4962ee64d33a/hal/maths/primes.py#L112-L135 | train |
lowandrew/OLCTools | spadespipeline/basicAssembly.py | Basic.readlength | def readlength(self):
"""Calculates the read length of the fastq files. Short reads will not be able to be assembled properly with the
default parameters used for spades."""
logging.info('Estimating read lengths of FASTQ files')
# Iterate through the samples
for sample in self.sa... | python | def readlength(self):
"""Calculates the read length of the fastq files. Short reads will not be able to be assembled properly with the
default parameters used for spades."""
logging.info('Estimating read lengths of FASTQ files')
# Iterate through the samples
for sample in self.sa... | [
"def",
"readlength",
"(",
"self",
")",
":",
"logging",
".",
"info",
"(",
"'Estimating read lengths of FASTQ files'",
")",
"for",
"sample",
"in",
"self",
".",
"samples",
":",
"sample",
".",
"run",
".",
"Date",
"=",
"'NA'",
"sample",
".",
"run",
".",
"Invest... | Calculates the read length of the fastq files. Short reads will not be able to be assembled properly with the
default parameters used for spades. | [
"Calculates",
"the",
"read",
"length",
"of",
"the",
"fastq",
"files",
".",
"Short",
"reads",
"will",
"not",
"be",
"able",
"to",
"be",
"assembled",
"properly",
"with",
"the",
"default",
"parameters",
"used",
"for",
"spades",
"."
] | 88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a | https://github.com/lowandrew/OLCTools/blob/88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a/spadespipeline/basicAssembly.py#L54-L128 | train |
dpa-newslab/livebridge | livebridge/storages/sql.py | SQLStorage.setup | async def setup(self):
"""Setting up SQL table, if it not exists."""
try:
engine = await self.db
created = False
if not await engine.has_table(self.table_name):
# create table
logger.info("Creating SQL table [{}]".format(self.table_name... | python | async def setup(self):
"""Setting up SQL table, if it not exists."""
try:
engine = await self.db
created = False
if not await engine.has_table(self.table_name):
# create table
logger.info("Creating SQL table [{}]".format(self.table_name... | [
"async",
"def",
"setup",
"(",
"self",
")",
":",
"try",
":",
"engine",
"=",
"await",
"self",
".",
"db",
"created",
"=",
"False",
"if",
"not",
"await",
"engine",
".",
"has_table",
"(",
"self",
".",
"table_name",
")",
":",
"logger",
".",
"info",
"(",
... | Setting up SQL table, if it not exists. | [
"Setting",
"up",
"SQL",
"table",
"if",
"it",
"not",
"exists",
"."
] | d930e887faa2f882d15b574f0f1fe4a580d7c5fa | https://github.com/dpa-newslab/livebridge/blob/d930e887faa2f882d15b574f0f1fe4a580d7c5fa/livebridge/storages/sql.py#L75-L103 | train |
aquatix/ns-api | ns_api.py | is_dst | def is_dst(zonename):
"""
Find out whether it's Daylight Saving Time in this timezone
"""
tz = pytz.timezone(zonename)
now = pytz.utc.localize(datetime.utcnow())
return now.astimezone(tz).dst() != timedelta(0) | python | def is_dst(zonename):
"""
Find out whether it's Daylight Saving Time in this timezone
"""
tz = pytz.timezone(zonename)
now = pytz.utc.localize(datetime.utcnow())
return now.astimezone(tz).dst() != timedelta(0) | [
"def",
"is_dst",
"(",
"zonename",
")",
":",
"tz",
"=",
"pytz",
".",
"timezone",
"(",
"zonename",
")",
"now",
"=",
"pytz",
".",
"utc",
".",
"localize",
"(",
"datetime",
".",
"utcnow",
"(",
")",
")",
"return",
"now",
".",
"astimezone",
"(",
"tz",
")"... | Find out whether it's Daylight Saving Time in this timezone | [
"Find",
"out",
"whether",
"it",
"s",
"Daylight",
"Saving",
"Time",
"in",
"this",
"timezone"
] | 9b3379f8df6217132f457c4363457c16321c2448 | https://github.com/aquatix/ns-api/blob/9b3379f8df6217132f457c4363457c16321c2448/ns_api.py#L43-L49 | train |
aquatix/ns-api | ns_api.py | load_datetime | def load_datetime(value, dt_format):
"""
Create timezone-aware datetime object
"""
if dt_format.endswith('%z'):
dt_format = dt_format[:-2]
offset = value[-5:]
value = value[:-5]
if offset != offset.replace(':', ''):
# strip : from HHMM if needed (isoformat() a... | python | def load_datetime(value, dt_format):
"""
Create timezone-aware datetime object
"""
if dt_format.endswith('%z'):
dt_format = dt_format[:-2]
offset = value[-5:]
value = value[:-5]
if offset != offset.replace(':', ''):
# strip : from HHMM if needed (isoformat() a... | [
"def",
"load_datetime",
"(",
"value",
",",
"dt_format",
")",
":",
"if",
"dt_format",
".",
"endswith",
"(",
"'%z'",
")",
":",
"dt_format",
"=",
"dt_format",
"[",
":",
"-",
"2",
"]",
"offset",
"=",
"value",
"[",
"-",
"5",
":",
"]",
"value",
"=",
"val... | Create timezone-aware datetime object | [
"Create",
"timezone",
"-",
"aware",
"datetime",
"object"
] | 9b3379f8df6217132f457c4363457c16321c2448 | https://github.com/aquatix/ns-api/blob/9b3379f8df6217132f457c4363457c16321c2448/ns_api.py#L62-L76 | train |
aquatix/ns-api | ns_api.py | list_to_json | def list_to_json(source_list):
"""
Serialise all the items in source_list to json
"""
result = []
for item in source_list:
result.append(item.to_json())
return result | python | def list_to_json(source_list):
"""
Serialise all the items in source_list to json
"""
result = []
for item in source_list:
result.append(item.to_json())
return result | [
"def",
"list_to_json",
"(",
"source_list",
")",
":",
"result",
"=",
"[",
"]",
"for",
"item",
"in",
"source_list",
":",
"result",
".",
"append",
"(",
"item",
".",
"to_json",
"(",
")",
")",
"return",
"result"
] | Serialise all the items in source_list to json | [
"Serialise",
"all",
"the",
"items",
"in",
"source_list",
"to",
"json"
] | 9b3379f8df6217132f457c4363457c16321c2448 | https://github.com/aquatix/ns-api/blob/9b3379f8df6217132f457c4363457c16321c2448/ns_api.py#L81-L88 | train |
aquatix/ns-api | ns_api.py | list_from_json | def list_from_json(source_list_json):
"""
Deserialise all the items in source_list from json
"""
result = []
if source_list_json == [] or source_list_json == None:
return result
for list_item in source_list_json:
item = json.loads(list_item)
try:
if item['clas... | python | def list_from_json(source_list_json):
"""
Deserialise all the items in source_list from json
"""
result = []
if source_list_json == [] or source_list_json == None:
return result
for list_item in source_list_json:
item = json.loads(list_item)
try:
if item['clas... | [
"def",
"list_from_json",
"(",
"source_list_json",
")",
":",
"result",
"=",
"[",
"]",
"if",
"source_list_json",
"==",
"[",
"]",
"or",
"source_list_json",
"==",
"None",
":",
"return",
"result",
"for",
"list_item",
"in",
"source_list_json",
":",
"item",
"=",
"j... | Deserialise all the items in source_list from json | [
"Deserialise",
"all",
"the",
"items",
"in",
"source_list",
"from",
"json"
] | 9b3379f8df6217132f457c4363457c16321c2448 | https://github.com/aquatix/ns-api/blob/9b3379f8df6217132f457c4363457c16321c2448/ns_api.py#L91-L123 | train |
aquatix/ns-api | ns_api.py | list_diff | def list_diff(list_a, list_b):
"""
Return the items from list_b that differ from list_a
"""
result = []
for item in list_b:
if not item in list_a:
result.append(item)
return result | python | def list_diff(list_a, list_b):
"""
Return the items from list_b that differ from list_a
"""
result = []
for item in list_b:
if not item in list_a:
result.append(item)
return result | [
"def",
"list_diff",
"(",
"list_a",
",",
"list_b",
")",
":",
"result",
"=",
"[",
"]",
"for",
"item",
"in",
"list_b",
":",
"if",
"not",
"item",
"in",
"list_a",
":",
"result",
".",
"append",
"(",
"item",
")",
"return",
"result"
] | Return the items from list_b that differ from list_a | [
"Return",
"the",
"items",
"from",
"list_b",
"that",
"differ",
"from",
"list_a"
] | 9b3379f8df6217132f457c4363457c16321c2448 | https://github.com/aquatix/ns-api/blob/9b3379f8df6217132f457c4363457c16321c2448/ns_api.py#L126-L134 | train |
aquatix/ns-api | ns_api.py | list_same | def list_same(list_a, list_b):
"""
Return the items from list_b that are also on list_a
"""
result = []
for item in list_b:
if item in list_a:
result.append(item)
return result | python | def list_same(list_a, list_b):
"""
Return the items from list_b that are also on list_a
"""
result = []
for item in list_b:
if item in list_a:
result.append(item)
return result | [
"def",
"list_same",
"(",
"list_a",
",",
"list_b",
")",
":",
"result",
"=",
"[",
"]",
"for",
"item",
"in",
"list_b",
":",
"if",
"item",
"in",
"list_a",
":",
"result",
".",
"append",
"(",
"item",
")",
"return",
"result"
] | Return the items from list_b that are also on list_a | [
"Return",
"the",
"items",
"from",
"list_b",
"that",
"are",
"also",
"on",
"list_a"
] | 9b3379f8df6217132f457c4363457c16321c2448 | https://github.com/aquatix/ns-api/blob/9b3379f8df6217132f457c4363457c16321c2448/ns_api.py#L137-L145 | train |
aquatix/ns-api | ns_api.py | list_merge | def list_merge(list_a, list_b):
"""
Merge two lists without duplicating items
Args:
list_a: list
list_b: list
Returns:
New list with deduplicated items from list_a and list_b
"""
#return list(collections.OrderedDict.fromkeys(list_a + list_b))
#result = list(list_b)
res... | python | def list_merge(list_a, list_b):
"""
Merge two lists without duplicating items
Args:
list_a: list
list_b: list
Returns:
New list with deduplicated items from list_a and list_b
"""
#return list(collections.OrderedDict.fromkeys(list_a + list_b))
#result = list(list_b)
res... | [
"def",
"list_merge",
"(",
"list_a",
",",
"list_b",
")",
":",
"result",
"=",
"[",
"]",
"for",
"item",
"in",
"list_a",
":",
"if",
"not",
"item",
"in",
"result",
":",
"result",
".",
"append",
"(",
"item",
")",
"for",
"item",
"in",
"list_b",
":",
"if",... | Merge two lists without duplicating items
Args:
list_a: list
list_b: list
Returns:
New list with deduplicated items from list_a and list_b | [
"Merge",
"two",
"lists",
"without",
"duplicating",
"items"
] | 9b3379f8df6217132f457c4363457c16321c2448 | https://github.com/aquatix/ns-api/blob/9b3379f8df6217132f457c4363457c16321c2448/ns_api.py#L148-L167 | train |
aquatix/ns-api | ns_api.py | Trip.delay | def delay(self):
"""
Return the delay of the train for this instance
"""
delay = {'departure_time': None, 'departure_delay': None, 'requested_differs': None,
'remarks': self.trip_remarks, 'parts': []}
if self.departure_time_actual > self.departure_time_planned:
... | python | def delay(self):
"""
Return the delay of the train for this instance
"""
delay = {'departure_time': None, 'departure_delay': None, 'requested_differs': None,
'remarks': self.trip_remarks, 'parts': []}
if self.departure_time_actual > self.departure_time_planned:
... | [
"def",
"delay",
"(",
"self",
")",
":",
"delay",
"=",
"{",
"'departure_time'",
":",
"None",
",",
"'departure_delay'",
":",
"None",
",",
"'requested_differs'",
":",
"None",
",",
"'remarks'",
":",
"self",
".",
"trip_remarks",
",",
"'parts'",
":",
"[",
"]",
... | Return the delay of the train for this instance | [
"Return",
"the",
"delay",
"of",
"the",
"train",
"for",
"this",
"instance"
] | 9b3379f8df6217132f457c4363457c16321c2448 | https://github.com/aquatix/ns-api/blob/9b3379f8df6217132f457c4363457c16321c2448/ns_api.py#L580-L594 | train |
aquatix/ns-api | ns_api.py | Trip.get_actual | def get_actual(cls, trip_list, time):
"""
Look for the train actually leaving at time
"""
for trip in trip_list:
if simple_time(trip.departure_time_planned) == time:
return trip
return None | python | def get_actual(cls, trip_list, time):
"""
Look for the train actually leaving at time
"""
for trip in trip_list:
if simple_time(trip.departure_time_planned) == time:
return trip
return None | [
"def",
"get_actual",
"(",
"cls",
",",
"trip_list",
",",
"time",
")",
":",
"for",
"trip",
"in",
"trip_list",
":",
"if",
"simple_time",
"(",
"trip",
".",
"departure_time_planned",
")",
"==",
"time",
":",
"return",
"trip",
"return",
"None"
] | Look for the train actually leaving at time | [
"Look",
"for",
"the",
"train",
"actually",
"leaving",
"at",
"time"
] | 9b3379f8df6217132f457c4363457c16321c2448 | https://github.com/aquatix/ns-api/blob/9b3379f8df6217132f457c4363457c16321c2448/ns_api.py#L674-L681 | train |
aquatix/ns-api | ns_api.py | NSAPI.parse_disruptions | def parse_disruptions(self, xml):
"""
Parse the NS API xml result into Disruption objects
@param xml: raw XML result from the NS API
"""
obj = xmltodict.parse(xml)
disruptions = {}
disruptions['unplanned'] = []
disruptions['planned'] = []
if obj['... | python | def parse_disruptions(self, xml):
"""
Parse the NS API xml result into Disruption objects
@param xml: raw XML result from the NS API
"""
obj = xmltodict.parse(xml)
disruptions = {}
disruptions['unplanned'] = []
disruptions['planned'] = []
if obj['... | [
"def",
"parse_disruptions",
"(",
"self",
",",
"xml",
")",
":",
"obj",
"=",
"xmltodict",
".",
"parse",
"(",
"xml",
")",
"disruptions",
"=",
"{",
"}",
"disruptions",
"[",
"'unplanned'",
"]",
"=",
"[",
"]",
"disruptions",
"[",
"'planned'",
"]",
"=",
"[",
... | Parse the NS API xml result into Disruption objects
@param xml: raw XML result from the NS API | [
"Parse",
"the",
"NS",
"API",
"xml",
"result",
"into",
"Disruption",
"objects"
] | 9b3379f8df6217132f457c4363457c16321c2448 | https://github.com/aquatix/ns-api/blob/9b3379f8df6217132f457c4363457c16321c2448/ns_api.py#L729-L756 | train |
aquatix/ns-api | ns_api.py | NSAPI.parse_departures | def parse_departures(self, xml):
"""
Parse the NS API xml result into Departure objects
@param xml: raw XML result from the NS API
"""
obj = xmltodict.parse(xml)
departures = []
for departure in obj['ActueleVertrekTijden']['VertrekkendeTrein']:
newdep... | python | def parse_departures(self, xml):
"""
Parse the NS API xml result into Departure objects
@param xml: raw XML result from the NS API
"""
obj = xmltodict.parse(xml)
departures = []
for departure in obj['ActueleVertrekTijden']['VertrekkendeTrein']:
newdep... | [
"def",
"parse_departures",
"(",
"self",
",",
"xml",
")",
":",
"obj",
"=",
"xmltodict",
".",
"parse",
"(",
"xml",
")",
"departures",
"=",
"[",
"]",
"for",
"departure",
"in",
"obj",
"[",
"'ActueleVertrekTijden'",
"]",
"[",
"'VertrekkendeTrein'",
"]",
":",
... | Parse the NS API xml result into Departure objects
@param xml: raw XML result from the NS API | [
"Parse",
"the",
"NS",
"API",
"xml",
"result",
"into",
"Departure",
"objects"
] | 9b3379f8df6217132f457c4363457c16321c2448 | https://github.com/aquatix/ns-api/blob/9b3379f8df6217132f457c4363457c16321c2448/ns_api.py#L776-L792 | train |
aquatix/ns-api | ns_api.py | NSAPI.parse_trips | def parse_trips(self, xml, requested_time):
"""
Parse the NS API xml result into Trip objects
"""
obj = xmltodict.parse(xml)
trips = []
if 'error' in obj:
print('Error in trips: ' + obj['error']['message'])
return None
try:
fo... | python | def parse_trips(self, xml, requested_time):
"""
Parse the NS API xml result into Trip objects
"""
obj = xmltodict.parse(xml)
trips = []
if 'error' in obj:
print('Error in trips: ' + obj['error']['message'])
return None
try:
fo... | [
"def",
"parse_trips",
"(",
"self",
",",
"xml",
",",
"requested_time",
")",
":",
"obj",
"=",
"xmltodict",
".",
"parse",
"(",
"xml",
")",
"trips",
"=",
"[",
"]",
"if",
"'error'",
"in",
"obj",
":",
"print",
"(",
"'Error in trips: '",
"+",
"obj",
"[",
"'... | Parse the NS API xml result into Trip objects | [
"Parse",
"the",
"NS",
"API",
"xml",
"result",
"into",
"Trip",
"objects"
] | 9b3379f8df6217132f457c4363457c16321c2448 | https://github.com/aquatix/ns-api/blob/9b3379f8df6217132f457c4363457c16321c2448/ns_api.py#L807-L826 | train |
aquatix/ns-api | ns_api.py | NSAPI.get_stations | def get_stations(self):
"""
Fetch the list of stations
"""
url = 'http://webservices.ns.nl/ns-api-stations-v2'
raw_stations = self._request('GET', url)
return self.parse_stations(raw_stations) | python | def get_stations(self):
"""
Fetch the list of stations
"""
url = 'http://webservices.ns.nl/ns-api-stations-v2'
raw_stations = self._request('GET', url)
return self.parse_stations(raw_stations) | [
"def",
"get_stations",
"(",
"self",
")",
":",
"url",
"=",
"'http://webservices.ns.nl/ns-api-stations-v2'",
"raw_stations",
"=",
"self",
".",
"_request",
"(",
"'GET'",
",",
"url",
")",
"return",
"self",
".",
"parse_stations",
"(",
"raw_stations",
")"
] | Fetch the list of stations | [
"Fetch",
"the",
"list",
"of",
"stations"
] | 9b3379f8df6217132f457c4363457c16321c2448 | https://github.com/aquatix/ns-api/blob/9b3379f8df6217132f457c4363457c16321c2448/ns_api.py#L877-L883 | train |
steven-lang/bottr | bottr/bot.py | AbstractBot.stop | def stop(self):
"""
Stops this bot.
Returns as soon as all running threads have finished processing.
"""
self.log.debug('Stopping bot {}'.format(self._name))
self._stop = True
for t in self._threads:
t.join()
self.log.debug('Stopping bot {} f... | python | def stop(self):
"""
Stops this bot.
Returns as soon as all running threads have finished processing.
"""
self.log.debug('Stopping bot {}'.format(self._name))
self._stop = True
for t in self._threads:
t.join()
self.log.debug('Stopping bot {} f... | [
"def",
"stop",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'Stopping bot {}'",
".",
"format",
"(",
"self",
".",
"_name",
")",
")",
"self",
".",
"_stop",
"=",
"True",
"for",
"t",
"in",
"self",
".",
"_threads",
":",
"t",
".",
"jo... | Stops this bot.
Returns as soon as all running threads have finished processing. | [
"Stops",
"this",
"bot",
"."
] | c1b92becc31adfbd5a7b77179b852a51da70b193 | https://github.com/steven-lang/bottr/blob/c1b92becc31adfbd5a7b77179b852a51da70b193/bottr/bot.py#L50-L61 | train |
steven-lang/bottr | bottr/bot.py | AbstractCommentBot._listen_comments | def _listen_comments(self):
"""Start listening to comments, using a separate thread."""
# Collect comments in a queue
comments_queue = Queue(maxsize=self._n_jobs * 4)
threads = [] # type: List[BotQueueWorker]
try:
# Create n_jobs CommentsThreads
for i ... | python | def _listen_comments(self):
"""Start listening to comments, using a separate thread."""
# Collect comments in a queue
comments_queue = Queue(maxsize=self._n_jobs * 4)
threads = [] # type: List[BotQueueWorker]
try:
# Create n_jobs CommentsThreads
for i ... | [
"def",
"_listen_comments",
"(",
"self",
")",
":",
"comments_queue",
"=",
"Queue",
"(",
"maxsize",
"=",
"self",
".",
"_n_jobs",
"*",
"4",
")",
"threads",
"=",
"[",
"]",
"try",
":",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"_n_jobs",
")",
":",
"t... | Start listening to comments, using a separate thread. | [
"Start",
"listening",
"to",
"comments",
"using",
"a",
"separate",
"thread",
"."
] | c1b92becc31adfbd5a7b77179b852a51da70b193 | https://github.com/steven-lang/bottr/blob/c1b92becc31adfbd5a7b77179b852a51da70b193/bottr/bot.py#L79-L115 | train |
steven-lang/bottr | bottr/bot.py | AbstractSubmissionBot._listen_submissions | def _listen_submissions(self):
"""Start listening to submissions, using a separate thread."""
# Collect submissions in a queue
subs_queue = Queue(maxsize=self._n_jobs * 4)
threads = [] # type: List[BotQueueWorker]
try:
# Create n_jobs SubmissionThreads
... | python | def _listen_submissions(self):
"""Start listening to submissions, using a separate thread."""
# Collect submissions in a queue
subs_queue = Queue(maxsize=self._n_jobs * 4)
threads = [] # type: List[BotQueueWorker]
try:
# Create n_jobs SubmissionThreads
... | [
"def",
"_listen_submissions",
"(",
"self",
")",
":",
"subs_queue",
"=",
"Queue",
"(",
"maxsize",
"=",
"self",
".",
"_n_jobs",
"*",
"4",
")",
"threads",
"=",
"[",
"]",
"try",
":",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"_n_jobs",
")",
":",
"t"... | Start listening to submissions, using a separate thread. | [
"Start",
"listening",
"to",
"submissions",
"using",
"a",
"separate",
"thread",
"."
] | c1b92becc31adfbd5a7b77179b852a51da70b193 | https://github.com/steven-lang/bottr/blob/c1b92becc31adfbd5a7b77179b852a51da70b193/bottr/bot.py#L137-L172 | train |
steven-lang/bottr | bottr/bot.py | AbstractMessageBot._listen_inbox_messages | def _listen_inbox_messages(self):
"""Start listening to messages, using a separate thread."""
# Collect messages in a queue
inbox_queue = Queue(maxsize=self._n_jobs * 4)
threads = [] # type: List[BotQueueWorker]
try:
# Create n_jobs inbox threads
for i ... | python | def _listen_inbox_messages(self):
"""Start listening to messages, using a separate thread."""
# Collect messages in a queue
inbox_queue = Queue(maxsize=self._n_jobs * 4)
threads = [] # type: List[BotQueueWorker]
try:
# Create n_jobs inbox threads
for i ... | [
"def",
"_listen_inbox_messages",
"(",
"self",
")",
":",
"inbox_queue",
"=",
"Queue",
"(",
"maxsize",
"=",
"self",
".",
"_n_jobs",
"*",
"4",
")",
"threads",
"=",
"[",
"]",
"try",
":",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"_n_jobs",
")",
":",
... | Start listening to messages, using a separate thread. | [
"Start",
"listening",
"to",
"messages",
"using",
"a",
"separate",
"thread",
"."
] | c1b92becc31adfbd5a7b77179b852a51da70b193 | https://github.com/steven-lang/bottr/blob/c1b92becc31adfbd5a7b77179b852a51da70b193/bottr/bot.py#L205-L239 | train |
hozn/keepassdb | keepassdb/model.py | BaseModel.to_struct | def to_struct(self):
"""
Initialize properties of the appropriate struct class from this model class.
"""
structobj = self.struct_type()
for k in structobj.attributes():
self.log.info("Setting attribute %s to %r" % (k, getattr(self, k)))
setattr(structobj,... | python | def to_struct(self):
"""
Initialize properties of the appropriate struct class from this model class.
"""
structobj = self.struct_type()
for k in structobj.attributes():
self.log.info("Setting attribute %s to %r" % (k, getattr(self, k)))
setattr(structobj,... | [
"def",
"to_struct",
"(",
"self",
")",
":",
"structobj",
"=",
"self",
".",
"struct_type",
"(",
")",
"for",
"k",
"in",
"structobj",
".",
"attributes",
"(",
")",
":",
"self",
".",
"log",
".",
"info",
"(",
"\"Setting attribute %s to %r\"",
"%",
"(",
"k",
"... | Initialize properties of the appropriate struct class from this model class. | [
"Initialize",
"properties",
"of",
"the",
"appropriate",
"struct",
"class",
"from",
"this",
"model",
"class",
"."
] | cb24985d1ed04e7d7db99ecdddf80dd1a91ee48b | https://github.com/hozn/keepassdb/blob/cb24985d1ed04e7d7db99ecdddf80dd1a91ee48b/keepassdb/model.py#L65-L73 | train |
hozn/keepassdb | keepassdb/model.py | Entry.move | def move(self, group, index=None):
"""
This method moves the entry to another group.
"""
return self.group.db.move_entry(self, group, index=index) | python | def move(self, group, index=None):
"""
This method moves the entry to another group.
"""
return self.group.db.move_entry(self, group, index=index) | [
"def",
"move",
"(",
"self",
",",
"group",
",",
"index",
"=",
"None",
")",
":",
"return",
"self",
".",
"group",
".",
"db",
".",
"move_entry",
"(",
"self",
",",
"group",
",",
"index",
"=",
"index",
")"
] | This method moves the entry to another group. | [
"This",
"method",
"moves",
"the",
"entry",
"to",
"another",
"group",
"."
] | cb24985d1ed04e7d7db99ecdddf80dd1a91ee48b | https://github.com/hozn/keepassdb/blob/cb24985d1ed04e7d7db99ecdddf80dd1a91ee48b/keepassdb/model.py#L447-L451 | train |
loganasherjones/yapconf | yapconf/__init__.py | dump_data | def dump_data(data,
filename=None,
file_type='json',
klazz=YapconfError,
open_kwargs=None,
dump_kwargs=None):
"""Dump data given to file or stdout in file_type.
Args:
data (dict): The dictionary to dump.
filename (str, option... | python | def dump_data(data,
filename=None,
file_type='json',
klazz=YapconfError,
open_kwargs=None,
dump_kwargs=None):
"""Dump data given to file or stdout in file_type.
Args:
data (dict): The dictionary to dump.
filename (str, option... | [
"def",
"dump_data",
"(",
"data",
",",
"filename",
"=",
"None",
",",
"file_type",
"=",
"'json'",
",",
"klazz",
"=",
"YapconfError",
",",
"open_kwargs",
"=",
"None",
",",
"dump_kwargs",
"=",
"None",
")",
":",
"_check_file_type",
"(",
"file_type",
",",
"klazz... | Dump data given to file or stdout in file_type.
Args:
data (dict): The dictionary to dump.
filename (str, optional): Defaults to None. The filename to write
the data to. If none is provided, it will be written to STDOUT.
file_type (str, optional): Defaults to 'json'. Can be any of
... | [
"Dump",
"data",
"given",
"to",
"file",
"or",
"stdout",
"in",
"file_type",
"."
] | d2970e6e7e3334615d4d978d8b0ca33006d79d16 | https://github.com/loganasherjones/yapconf/blob/d2970e6e7e3334615d4d978d8b0ca33006d79d16/yapconf/__init__.py#L111-L140 | train |
loganasherjones/yapconf | yapconf/__init__.py | load_file | def load_file(filename,
file_type='json',
klazz=YapconfError,
open_kwargs=None,
load_kwargs=None):
"""Load a file with the given file type.
Args:
filename (str): The filename to load.
file_type (str, optional): Defaults to 'json'. The file... | python | def load_file(filename,
file_type='json',
klazz=YapconfError,
open_kwargs=None,
load_kwargs=None):
"""Load a file with the given file type.
Args:
filename (str): The filename to load.
file_type (str, optional): Defaults to 'json'. The file... | [
"def",
"load_file",
"(",
"filename",
",",
"file_type",
"=",
"'json'",
",",
"klazz",
"=",
"YapconfError",
",",
"open_kwargs",
"=",
"None",
",",
"load_kwargs",
"=",
"None",
")",
":",
"_check_file_type",
"(",
"file_type",
",",
"klazz",
")",
"open_kwargs",
"=",
... | Load a file with the given file type.
Args:
filename (str): The filename to load.
file_type (str, optional): Defaults to 'json'. The file type for the
given filename. Supported types are ``yapconf.FILE_TYPES```
klazz (optional): The custom exception to raise if something goes
... | [
"Load",
"a",
"file",
"with",
"the",
"given",
"file",
"type",
"."
] | d2970e6e7e3334615d4d978d8b0ca33006d79d16 | https://github.com/loganasherjones/yapconf/blob/d2970e6e7e3334615d4d978d8b0ca33006d79d16/yapconf/__init__.py#L172-L214 | train |
loganasherjones/yapconf | yapconf/__init__.py | flatten | def flatten(dictionary, separator='.', prefix=''):
"""Flatten the dictionary keys are separated by separator
Arguments:
dictionary {dict} -- The dictionary to be flattened.
Keyword Arguments:
separator {str} -- The separator to use (default is '.'). It will
crush items with key con... | python | def flatten(dictionary, separator='.', prefix=''):
"""Flatten the dictionary keys are separated by separator
Arguments:
dictionary {dict} -- The dictionary to be flattened.
Keyword Arguments:
separator {str} -- The separator to use (default is '.'). It will
crush items with key con... | [
"def",
"flatten",
"(",
"dictionary",
",",
"separator",
"=",
"'.'",
",",
"prefix",
"=",
"''",
")",
":",
"new_dict",
"=",
"{",
"}",
"for",
"key",
",",
"value",
"in",
"dictionary",
".",
"items",
"(",
")",
":",
"new_key",
"=",
"prefix",
"+",
"separator",... | Flatten the dictionary keys are separated by separator
Arguments:
dictionary {dict} -- The dictionary to be flattened.
Keyword Arguments:
separator {str} -- The separator to use (default is '.'). It will
crush items with key conflicts.
prefix {str} -- Used for recursive calls.
... | [
"Flatten",
"the",
"dictionary",
"keys",
"are",
"separated",
"by",
"separator"
] | d2970e6e7e3334615d4d978d8b0ca33006d79d16 | https://github.com/loganasherjones/yapconf/blob/d2970e6e7e3334615d4d978d8b0ca33006d79d16/yapconf/__init__.py#L228-L260 | train |
kevinconway/venvctrl | venvctrl/cli/relocate.py | relocate | def relocate(source, destination, move=False):
"""Adjust the virtual environment settings and optional move it.
Args:
source (str): Path to the existing virtual environment.
destination (str): Desired path of the virtual environment.
move (bool): Whether or not to actually move the file... | python | def relocate(source, destination, move=False):
"""Adjust the virtual environment settings and optional move it.
Args:
source (str): Path to the existing virtual environment.
destination (str): Desired path of the virtual environment.
move (bool): Whether or not to actually move the file... | [
"def",
"relocate",
"(",
"source",
",",
"destination",
",",
"move",
"=",
"False",
")",
":",
"venv",
"=",
"api",
".",
"VirtualEnvironment",
"(",
"source",
")",
"if",
"not",
"move",
":",
"venv",
".",
"relocate",
"(",
"destination",
")",
"return",
"None",
... | Adjust the virtual environment settings and optional move it.
Args:
source (str): Path to the existing virtual environment.
destination (str): Desired path of the virtual environment.
move (bool): Whether or not to actually move the files. Default False. | [
"Adjust",
"the",
"virtual",
"environment",
"settings",
"and",
"optional",
"move",
"it",
"."
] | 36d4e0e4d5ebced6385a6ade1198f4769ff2df41 | https://github.com/kevinconway/venvctrl/blob/36d4e0e4d5ebced6385a6ade1198f4769ff2df41/venvctrl/cli/relocate.py#L13-L28 | train |
kevinconway/venvctrl | venvctrl/cli/relocate.py | main | def main():
"""Relocate a virtual environment."""
parser = argparse.ArgumentParser(
description='Relocate a virtual environment.'
)
parser.add_argument(
'--source',
help='The existing virtual environment.',
required=True,
)
parser.add_argument(
'--destinat... | python | def main():
"""Relocate a virtual environment."""
parser = argparse.ArgumentParser(
description='Relocate a virtual environment.'
)
parser.add_argument(
'--source',
help='The existing virtual environment.',
required=True,
)
parser.add_argument(
'--destinat... | [
"def",
"main",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"'Relocate a virtual environment.'",
")",
"parser",
".",
"add_argument",
"(",
"'--source'",
",",
"help",
"=",
"'The existing virtual environment.'",
",",
"requir... | Relocate a virtual environment. | [
"Relocate",
"a",
"virtual",
"environment",
"."
] | 36d4e0e4d5ebced6385a6ade1198f4769ff2df41 | https://github.com/kevinconway/venvctrl/blob/36d4e0e4d5ebced6385a6ade1198f4769ff2df41/venvctrl/cli/relocate.py#L31-L54 | train |
wylee/runcommands | runcommands/util/prompt.py | confirm | def confirm(prompt='Really?', color='warning', yes_values=('y', 'yes'),
abort_on_unconfirmed=False, abort_options=None):
"""Prompt for confirmation.
Confirmation can be aborted by typing in a no value instead of one
of the yes values or with Ctrl-C.
Args:
prompt (str): Prompt to pr... | python | def confirm(prompt='Really?', color='warning', yes_values=('y', 'yes'),
abort_on_unconfirmed=False, abort_options=None):
"""Prompt for confirmation.
Confirmation can be aborted by typing in a no value instead of one
of the yes values or with Ctrl-C.
Args:
prompt (str): Prompt to pr... | [
"def",
"confirm",
"(",
"prompt",
"=",
"'Really?'",
",",
"color",
"=",
"'warning'",
",",
"yes_values",
"=",
"(",
"'y'",
",",
"'yes'",
")",
",",
"abort_on_unconfirmed",
"=",
"False",
",",
"abort_options",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"ye... | Prompt for confirmation.
Confirmation can be aborted by typing in a no value instead of one
of the yes values or with Ctrl-C.
Args:
prompt (str): Prompt to present user ["Really?"]
color (string|Color|bool) Color to print prompt string; can be
``False`` or ``None`` to print wit... | [
"Prompt",
"for",
"confirmation",
"."
] | b1d7c262885b9ced7ab89b63562f5464ca9970fe | https://github.com/wylee/runcommands/blob/b1d7c262885b9ced7ab89b63562f5464ca9970fe/runcommands/util/prompt.py#L5-L78 | train |
sirfoga/pyhal | hal/internet/email/templates.py | EmailTemplate.get_mime_message | def get_mime_message(self):
"""Gets email MIME message
:return: Email formatted as HTML ready to be sent
"""
message = MIMEText(
"<html>" +
self.get_email_header() +
get_email_content(self.content_file) +
self.get_email_footer() +
... | python | def get_mime_message(self):
"""Gets email MIME message
:return: Email formatted as HTML ready to be sent
"""
message = MIMEText(
"<html>" +
self.get_email_header() +
get_email_content(self.content_file) +
self.get_email_footer() +
... | [
"def",
"get_mime_message",
"(",
"self",
")",
":",
"message",
"=",
"MIMEText",
"(",
"\"<html>\"",
"+",
"self",
".",
"get_email_header",
"(",
")",
"+",
"get_email_content",
"(",
"self",
".",
"content_file",
")",
"+",
"self",
".",
"get_email_footer",
"(",
")",
... | Gets email MIME message
:return: Email formatted as HTML ready to be sent | [
"Gets",
"email",
"MIME",
"message"
] | 4394d8a1f7e45bea28a255ec390f4962ee64d33a | https://github.com/sirfoga/pyhal/blob/4394d8a1f7e45bea28a255ec390f4962ee64d33a/hal/internet/email/templates.py#L45-L58 | train |
freshbooks/statsdecor | statsdecor/decorators.py | increment | def increment(name, tags=None):
"""Function decorator for incrementing a statsd stat whenever
a function is invoked.
>>> from statsdecor.decorators import increment
>>> @increment('my.metric')
>>> def my_func():
>>> pass
"""
def wrap(f):
@wraps(f)
def decorator(*args... | python | def increment(name, tags=None):
"""Function decorator for incrementing a statsd stat whenever
a function is invoked.
>>> from statsdecor.decorators import increment
>>> @increment('my.metric')
>>> def my_func():
>>> pass
"""
def wrap(f):
@wraps(f)
def decorator(*args... | [
"def",
"increment",
"(",
"name",
",",
"tags",
"=",
"None",
")",
":",
"def",
"wrap",
"(",
"f",
")",
":",
"@",
"wraps",
"(",
"f",
")",
"def",
"decorator",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"stats",
"=",
"client",
"(",
")",
"ret",
... | Function decorator for incrementing a statsd stat whenever
a function is invoked.
>>> from statsdecor.decorators import increment
>>> @increment('my.metric')
>>> def my_func():
>>> pass | [
"Function",
"decorator",
"for",
"incrementing",
"a",
"statsd",
"stat",
"whenever",
"a",
"function",
"is",
"invoked",
"."
] | 1c4a98e120799b430fd40c8fede9020a91162d31 | https://github.com/freshbooks/statsdecor/blob/1c4a98e120799b430fd40c8fede9020a91162d31/statsdecor/decorators.py#L5-L22 | train |
freshbooks/statsdecor | statsdecor/decorators.py | decrement | def decrement(name, tags=None):
"""Function decorator for decrementing a statsd stat whenever
a function is invoked.
>>> from statsdecor.decorators import decrement
>>> @decrement('my.metric')
>>> def my_func():
>>> pass
"""
def wrap(f):
@wraps(f)
def decorator(*args... | python | def decrement(name, tags=None):
"""Function decorator for decrementing a statsd stat whenever
a function is invoked.
>>> from statsdecor.decorators import decrement
>>> @decrement('my.metric')
>>> def my_func():
>>> pass
"""
def wrap(f):
@wraps(f)
def decorator(*args... | [
"def",
"decrement",
"(",
"name",
",",
"tags",
"=",
"None",
")",
":",
"def",
"wrap",
"(",
"f",
")",
":",
"@",
"wraps",
"(",
"f",
")",
"def",
"decorator",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"stats",
"=",
"client",
"(",
")",
"ret",
... | Function decorator for decrementing a statsd stat whenever
a function is invoked.
>>> from statsdecor.decorators import decrement
>>> @decrement('my.metric')
>>> def my_func():
>>> pass | [
"Function",
"decorator",
"for",
"decrementing",
"a",
"statsd",
"stat",
"whenever",
"a",
"function",
"is",
"invoked",
"."
] | 1c4a98e120799b430fd40c8fede9020a91162d31 | https://github.com/freshbooks/statsdecor/blob/1c4a98e120799b430fd40c8fede9020a91162d31/statsdecor/decorators.py#L25-L42 | train |
freshbooks/statsdecor | statsdecor/decorators.py | timed | def timed(name, tags=None):
"""Function decorator for tracking timing information
on a function's invocation.
>>> from statsdecor.decorators import timed
>>> @timed('my.metric')
>>> def my_func():
>>> pass
"""
def wrap(f):
@wraps(f)
def decorator(*args, **kwargs):
... | python | def timed(name, tags=None):
"""Function decorator for tracking timing information
on a function's invocation.
>>> from statsdecor.decorators import timed
>>> @timed('my.metric')
>>> def my_func():
>>> pass
"""
def wrap(f):
@wraps(f)
def decorator(*args, **kwargs):
... | [
"def",
"timed",
"(",
"name",
",",
"tags",
"=",
"None",
")",
":",
"def",
"wrap",
"(",
"f",
")",
":",
"@",
"wraps",
"(",
"f",
")",
"def",
"decorator",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"stats",
"=",
"client",
"(",
")",
"with",
"s... | Function decorator for tracking timing information
on a function's invocation.
>>> from statsdecor.decorators import timed
>>> @timed('my.metric')
>>> def my_func():
>>> pass | [
"Function",
"decorator",
"for",
"tracking",
"timing",
"information",
"on",
"a",
"function",
"s",
"invocation",
"."
] | 1c4a98e120799b430fd40c8fede9020a91162d31 | https://github.com/freshbooks/statsdecor/blob/1c4a98e120799b430fd40c8fede9020a91162d31/statsdecor/decorators.py#L45-L61 | train |
sirfoga/pyhal | hal/files/models/files.py | Document.move_file_to_directory | def move_file_to_directory(file_path, directory_path):
"""Moves file to given directory
:param file_path: path to file to move
:param directory_path: path to target directory where to move file
"""
file_name = os.path.basename(file_path) # get name of file
if not os.pat... | python | def move_file_to_directory(file_path, directory_path):
"""Moves file to given directory
:param file_path: path to file to move
:param directory_path: path to target directory where to move file
"""
file_name = os.path.basename(file_path) # get name of file
if not os.pat... | [
"def",
"move_file_to_directory",
"(",
"file_path",
",",
"directory_path",
")",
":",
"file_name",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"file_path",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"directory_path",
")",
":",
"os",
".",
"m... | Moves file to given directory
:param file_path: path to file to move
:param directory_path: path to target directory where to move file | [
"Moves",
"file",
"to",
"given",
"directory"
] | 4394d8a1f7e45bea28a255ec390f4962ee64d33a | https://github.com/sirfoga/pyhal/blob/4394d8a1f7e45bea28a255ec390f4962ee64d33a/hal/files/models/files.py#L25-L35 | train |
sirfoga/pyhal | hal/files/models/files.py | Document.move_file_to_file | def move_file_to_file(old_path, new_path):
"""Moves file from old location to new one
:param old_path: path of file to move
:param new_path: new path
"""
try:
os.rename(old_path, new_path)
except:
old_file = os.path.basename(old_path)
... | python | def move_file_to_file(old_path, new_path):
"""Moves file from old location to new one
:param old_path: path of file to move
:param new_path: new path
"""
try:
os.rename(old_path, new_path)
except:
old_file = os.path.basename(old_path)
... | [
"def",
"move_file_to_file",
"(",
"old_path",
",",
"new_path",
")",
":",
"try",
":",
"os",
".",
"rename",
"(",
"old_path",
",",
"new_path",
")",
"except",
":",
"old_file",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"old_path",
")",
"target_directory",
... | Moves file from old location to new one
:param old_path: path of file to move
:param new_path: new path | [
"Moves",
"file",
"from",
"old",
"location",
"to",
"new",
"one"
] | 4394d8a1f7e45bea28a255ec390f4962ee64d33a | https://github.com/sirfoga/pyhal/blob/4394d8a1f7e45bea28a255ec390f4962ee64d33a/hal/files/models/files.py#L38-L55 | train |
sirfoga/pyhal | hal/files/models/files.py | Document.write_data | def write_data(self, data):
"""Writes given data to given path file
:param data: data to write to file
"""
with open(self.path, "w") as writer:
writer.write(data) | python | def write_data(self, data):
"""Writes given data to given path file
:param data: data to write to file
"""
with open(self.path, "w") as writer:
writer.write(data) | [
"def",
"write_data",
"(",
"self",
",",
"data",
")",
":",
"with",
"open",
"(",
"self",
".",
"path",
",",
"\"w\"",
")",
"as",
"writer",
":",
"writer",
".",
"write",
"(",
"data",
")"
] | Writes given data to given path file
:param data: data to write to file | [
"Writes",
"given",
"data",
"to",
"given",
"path",
"file"
] | 4394d8a1f7e45bea28a255ec390f4962ee64d33a | https://github.com/sirfoga/pyhal/blob/4394d8a1f7e45bea28a255ec390f4962ee64d33a/hal/files/models/files.py#L57-L63 | train |
sirfoga/pyhal | hal/files/models/files.py | Document.get_path_name | def get_path_name(self):
"""Gets path and name of song
:return: Name of path, name of file (or folder)
"""
path = fix_raw_path(os.path.dirname(os.path.abspath(self.path)))
name = os.path.basename(self.path)
return path, name | python | def get_path_name(self):
"""Gets path and name of song
:return: Name of path, name of file (or folder)
"""
path = fix_raw_path(os.path.dirname(os.path.abspath(self.path)))
name = os.path.basename(self.path)
return path, name | [
"def",
"get_path_name",
"(",
"self",
")",
":",
"path",
"=",
"fix_raw_path",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"abspath",
"(",
"self",
".",
"path",
")",
")",
")",
"name",
"=",
"os",
".",
"path",
".",
"basename",
... | Gets path and name of song
:return: Name of path, name of file (or folder) | [
"Gets",
"path",
"and",
"name",
"of",
"song"
] | 4394d8a1f7e45bea28a255ec390f4962ee64d33a | https://github.com/sirfoga/pyhal/blob/4394d8a1f7e45bea28a255ec390f4962ee64d33a/hal/files/models/files.py#L84-L91 | train |
sirfoga/pyhal | hal/files/models/files.py | Directory.get_path_name | def get_path_name(self):
"""Gets path and name of file
:return: Name of path, name of file (or folder)
"""
complete_path = os.path.dirname(os.path.abspath(self.path))
name = self.path.replace(complete_path + PATH_SEPARATOR, "")
if name.endswith("/"):
name = n... | python | def get_path_name(self):
"""Gets path and name of file
:return: Name of path, name of file (or folder)
"""
complete_path = os.path.dirname(os.path.abspath(self.path))
name = self.path.replace(complete_path + PATH_SEPARATOR, "")
if name.endswith("/"):
name = n... | [
"def",
"get_path_name",
"(",
"self",
")",
":",
"complete_path",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"abspath",
"(",
"self",
".",
"path",
")",
")",
"name",
"=",
"self",
".",
"path",
".",
"replace",
"(",
"complete_path"... | Gets path and name of file
:return: Name of path, name of file (or folder) | [
"Gets",
"path",
"and",
"name",
"of",
"file"
] | 4394d8a1f7e45bea28a255ec390f4962ee64d33a | https://github.com/sirfoga/pyhal/blob/4394d8a1f7e45bea28a255ec390f4962ee64d33a/hal/files/models/files.py#L152-L162 | train |
ArabellaTech/django-basic-cms | basic_cms/placeholders.py | PlaceholderNode.save | def save(self, page, language, data, change, extra_data=None):
"""Actually save the placeholder data into the Content object."""
# if this placeholder is untranslated, we save everything
# in the default language
if self.untranslated:
language = settings.PAGE_DEFAULT_LANGUAGE... | python | def save(self, page, language, data, change, extra_data=None):
"""Actually save the placeholder data into the Content object."""
# if this placeholder is untranslated, we save everything
# in the default language
if self.untranslated:
language = settings.PAGE_DEFAULT_LANGUAGE... | [
"def",
"save",
"(",
"self",
",",
"page",
",",
"language",
",",
"data",
",",
"change",
",",
"extra_data",
"=",
"None",
")",
":",
"if",
"self",
".",
"untranslated",
":",
"language",
"=",
"settings",
".",
"PAGE_DEFAULT_LANGUAGE",
"if",
"change",
":",
"if",
... | Actually save the placeholder data into the Content object. | [
"Actually",
"save",
"the",
"placeholder",
"data",
"into",
"the",
"Content",
"object",
"."
] | 863f3c6098606f663994930cd8e7723ad0c07caf | https://github.com/ArabellaTech/django-basic-cms/blob/863f3c6098606f663994930cd8e7723ad0c07caf/basic_cms/placeholders.py#L156-L188 | train |
ArabellaTech/django-basic-cms | basic_cms/placeholders.py | PlaceholderNode.render | def render(self, context):
"""Output the content of the `PlaceholdeNode` in the template."""
content = mark_safe(self.get_content_from_context(context))
if not content:
return ''
if self.parsed:
try:
t = template.Template(content, name=self.name)
... | python | def render(self, context):
"""Output the content of the `PlaceholdeNode` in the template."""
content = mark_safe(self.get_content_from_context(context))
if not content:
return ''
if self.parsed:
try:
t = template.Template(content, name=self.name)
... | [
"def",
"render",
"(",
"self",
",",
"context",
")",
":",
"content",
"=",
"mark_safe",
"(",
"self",
".",
"get_content_from_context",
"(",
"context",
")",
")",
"if",
"not",
"content",
":",
"return",
"''",
"if",
"self",
".",
"parsed",
":",
"try",
":",
"t",... | Output the content of the `PlaceholdeNode` in the template. | [
"Output",
"the",
"content",
"of",
"the",
"PlaceholdeNode",
"in",
"the",
"template",
"."
] | 863f3c6098606f663994930cd8e7723ad0c07caf | https://github.com/ArabellaTech/django-basic-cms/blob/863f3c6098606f663994930cd8e7723ad0c07caf/basic_cms/placeholders.py#L219-L240 | train |
Frzk/Ellis | ellis/action.py | Action.from_string | def from_string(cls, action_str):
"""
Creates a new Action instance from the given string.
The given string **must** match one of those patterns:
* module.function
* module.function()
* module.function(arg1=value1, arg2=value2)
Any other form will t... | python | def from_string(cls, action_str):
"""
Creates a new Action instance from the given string.
The given string **must** match one of those patterns:
* module.function
* module.function()
* module.function(arg1=value1, arg2=value2)
Any other form will t... | [
"def",
"from_string",
"(",
"cls",
",",
"action_str",
")",
":",
"args",
"=",
"{",
"}",
"try",
":",
"mod_obj",
"=",
"ast",
".",
"parse",
"(",
"action_str",
")",
"except",
"(",
"SyntaxError",
",",
"ValueError",
")",
"as",
"e",
":",
"raise",
"e",
"else",... | Creates a new Action instance from the given string.
The given string **must** match one of those patterns:
* module.function
* module.function()
* module.function(arg1=value1, arg2=value2)
Any other form will trigger an Exception.
The function parses the ... | [
"Creates",
"a",
"new",
"Action",
"instance",
"from",
"the",
"given",
"string",
"."
] | 39ce8987cbc503354cf1f45927344186a8b18363 | https://github.com/Frzk/Ellis/blob/39ce8987cbc503354cf1f45927344186a8b18363/ellis/action.py#L143-L213 | train |
ArabellaTech/django-basic-cms | basic_cms/managers.py | ContentManager.sanitize | def sanitize(self, content):
"""Sanitize a string in order to avoid possible XSS using
``html5lib``."""
import html5lib
from html5lib import sanitizer
p = html5lib.HTMLParser(tokenizer=sanitizer.HTMLSanitizer)
dom_tree = p.parseFragment(content)
return dom_tree.te... | python | def sanitize(self, content):
"""Sanitize a string in order to avoid possible XSS using
``html5lib``."""
import html5lib
from html5lib import sanitizer
p = html5lib.HTMLParser(tokenizer=sanitizer.HTMLSanitizer)
dom_tree = p.parseFragment(content)
return dom_tree.te... | [
"def",
"sanitize",
"(",
"self",
",",
"content",
")",
":",
"import",
"html5lib",
"from",
"html5lib",
"import",
"sanitizer",
"p",
"=",
"html5lib",
".",
"HTMLParser",
"(",
"tokenizer",
"=",
"sanitizer",
".",
"HTMLSanitizer",
")",
"dom_tree",
"=",
"p",
".",
"p... | Sanitize a string in order to avoid possible XSS using
``html5lib``. | [
"Sanitize",
"a",
"string",
"in",
"order",
"to",
"avoid",
"possible",
"XSS",
"using",
"html5lib",
"."
] | 863f3c6098606f663994930cd8e7723ad0c07caf | https://github.com/ArabellaTech/django-basic-cms/blob/863f3c6098606f663994930cd8e7723ad0c07caf/basic_cms/managers.py#L273-L280 | train |
TorkamaniLab/metapipe | metapipe/parser.py | Parser.consume | def consume(self, cwd=None):
""" Converts the lexer tokens into valid statements. This process
also checks command syntax.
"""
first_pass = Grammar.overall.parseString(self.string)
lowered = { key.lower(): val for key, val in first_pass.iteritems() }
self.commands = ['\n... | python | def consume(self, cwd=None):
""" Converts the lexer tokens into valid statements. This process
also checks command syntax.
"""
first_pass = Grammar.overall.parseString(self.string)
lowered = { key.lower(): val for key, val in first_pass.iteritems() }
self.commands = ['\n... | [
"def",
"consume",
"(",
"self",
",",
"cwd",
"=",
"None",
")",
":",
"first_pass",
"=",
"Grammar",
".",
"overall",
".",
"parseString",
"(",
"self",
".",
"string",
")",
"lowered",
"=",
"{",
"key",
".",
"lower",
"(",
")",
":",
"val",
"for",
"key",
",",
... | Converts the lexer tokens into valid statements. This process
also checks command syntax. | [
"Converts",
"the",
"lexer",
"tokens",
"into",
"valid",
"statements",
".",
"This",
"process",
"also",
"checks",
"command",
"syntax",
"."
] | 15592e5b0c217afb00ac03503f8d0d7453d4baf4 | https://github.com/TorkamaniLab/metapipe/blob/15592e5b0c217afb00ac03503f8d0d7453d4baf4/metapipe/parser.py#L17-L56 | train |
TorkamaniLab/metapipe | metapipe/parser.py | Parser._get | def _get(self, key, parser_result):
""" Given a type and a dict of parser results, return
the items as a list.
"""
try:
list_data = parser_result[key].asList()
if any(isinstance(obj, str) for obj in list_data):
txt_lines = [''.join(list_data)]
... | python | def _get(self, key, parser_result):
""" Given a type and a dict of parser results, return
the items as a list.
"""
try:
list_data = parser_result[key].asList()
if any(isinstance(obj, str) for obj in list_data):
txt_lines = [''.join(list_data)]
... | [
"def",
"_get",
"(",
"self",
",",
"key",
",",
"parser_result",
")",
":",
"try",
":",
"list_data",
"=",
"parser_result",
"[",
"key",
"]",
".",
"asList",
"(",
")",
"if",
"any",
"(",
"isinstance",
"(",
"obj",
",",
"str",
")",
"for",
"obj",
"in",
"list_... | Given a type and a dict of parser results, return
the items as a list. | [
"Given",
"a",
"type",
"and",
"a",
"dict",
"of",
"parser",
"results",
"return",
"the",
"items",
"as",
"a",
"list",
"."
] | 15592e5b0c217afb00ac03503f8d0d7453d4baf4 | https://github.com/TorkamaniLab/metapipe/blob/15592e5b0c217afb00ac03503f8d0d7453d4baf4/metapipe/parser.py#L58-L70 | train |
TorkamaniLab/metapipe | metapipe/parser.py | Parser._parse | def _parse(self, lines, grammar, ignore_comments=False):
""" Given a type and a list, parse it using the more detailed
parse grammar.
"""
results = []
for c in lines:
if c != '' and not (ignore_comments and c[0] == '#'):
try:
result... | python | def _parse(self, lines, grammar, ignore_comments=False):
""" Given a type and a list, parse it using the more detailed
parse grammar.
"""
results = []
for c in lines:
if c != '' and not (ignore_comments and c[0] == '#'):
try:
result... | [
"def",
"_parse",
"(",
"self",
",",
"lines",
",",
"grammar",
",",
"ignore_comments",
"=",
"False",
")",
":",
"results",
"=",
"[",
"]",
"for",
"c",
"in",
"lines",
":",
"if",
"c",
"!=",
"''",
"and",
"not",
"(",
"ignore_comments",
"and",
"c",
"[",
"0",... | Given a type and a list, parse it using the more detailed
parse grammar. | [
"Given",
"a",
"type",
"and",
"a",
"list",
"parse",
"it",
"using",
"the",
"more",
"detailed",
"parse",
"grammar",
"."
] | 15592e5b0c217afb00ac03503f8d0d7453d4baf4 | https://github.com/TorkamaniLab/metapipe/blob/15592e5b0c217afb00ac03503f8d0d7453d4baf4/metapipe/parser.py#L72-L84 | train |
lowandrew/OLCTools | metagenomefilter/automateCLARK.py | CLARK.objectprep | def objectprep(self):
"""Create objects to store data and metadata for each sample. Also, perform necessary file manipulations"""
# Move the files to subfolders and create objects
self.runmetadata = createobject.ObjectCreation(self)
if self.extension == 'fastq':
# To streamli... | python | def objectprep(self):
"""Create objects to store data and metadata for each sample. Also, perform necessary file manipulations"""
# Move the files to subfolders and create objects
self.runmetadata = createobject.ObjectCreation(self)
if self.extension == 'fastq':
# To streamli... | [
"def",
"objectprep",
"(",
"self",
")",
":",
"self",
".",
"runmetadata",
"=",
"createobject",
".",
"ObjectCreation",
"(",
"self",
")",
"if",
"self",
".",
"extension",
"==",
"'fastq'",
":",
"logging",
".",
"info",
"(",
"'Decompressing and combining .fastq files fo... | Create objects to store data and metadata for each sample. Also, perform necessary file manipulations | [
"Create",
"objects",
"to",
"store",
"data",
"and",
"metadata",
"for",
"each",
"sample",
".",
"Also",
"perform",
"necessary",
"file",
"manipulations"
] | 88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a | https://github.com/lowandrew/OLCTools/blob/88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a/metagenomefilter/automateCLARK.py#L38-L49 | train |
lowandrew/OLCTools | metagenomefilter/automateCLARK.py | CLARK.settargets | def settargets(self):
"""Set the targets to be used in the analyses. Involves the path of the database files, the database files to
use, and the level of classification for the analysis"""
# Define the set targets call. Include the path to the script, the database path and files, as well
... | python | def settargets(self):
"""Set the targets to be used in the analyses. Involves the path of the database files, the database files to
use, and the level of classification for the analysis"""
# Define the set targets call. Include the path to the script, the database path and files, as well
... | [
"def",
"settargets",
"(",
"self",
")",
":",
"logging",
".",
"info",
"(",
"'Setting up database'",
")",
"self",
".",
"targetcall",
"=",
"'cd {} && ./set_targets.sh {} {} --{}'",
".",
"format",
"(",
"self",
".",
"clarkpath",
",",
"self",
".",
"databasepath",
",",
... | Set the targets to be used in the analyses. Involves the path of the database files, the database files to
use, and the level of classification for the analysis | [
"Set",
"the",
"targets",
"to",
"be",
"used",
"in",
"the",
"analyses",
".",
"Involves",
"the",
"path",
"of",
"the",
"database",
"files",
"the",
"database",
"files",
"to",
"use",
"and",
"the",
"level",
"of",
"classification",
"for",
"the",
"analysis"
] | 88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a | https://github.com/lowandrew/OLCTools/blob/88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a/metagenomefilter/automateCLARK.py#L51-L60 | train |
lowandrew/OLCTools | metagenomefilter/automateCLARK.py | CLARK.classifymetagenome | def classifymetagenome(self):
"""Run the classify metagenome of the CLARK package on the samples"""
logging.info('Classifying metagenomes')
# Define the system call
self.classifycall = 'cd {} && ./classify_metagenome.sh -O {} -R {} -n {} --light'\
.format(self.clarkpath,
... | python | def classifymetagenome(self):
"""Run the classify metagenome of the CLARK package on the samples"""
logging.info('Classifying metagenomes')
# Define the system call
self.classifycall = 'cd {} && ./classify_metagenome.sh -O {} -R {} -n {} --light'\
.format(self.clarkpath,
... | [
"def",
"classifymetagenome",
"(",
"self",
")",
":",
"logging",
".",
"info",
"(",
"'Classifying metagenomes'",
")",
"self",
".",
"classifycall",
"=",
"'cd {} && ./classify_metagenome.sh -O {} -R {} -n {} --light'",
".",
"format",
"(",
"self",
".",
"clarkpath",
",",
"se... | Run the classify metagenome of the CLARK package on the samples | [
"Run",
"the",
"classify",
"metagenome",
"of",
"the",
"CLARK",
"package",
"on",
"the",
"samples"
] | 88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a | https://github.com/lowandrew/OLCTools/blob/88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a/metagenomefilter/automateCLARK.py#L80-L103 | train |
lowandrew/OLCTools | metagenomefilter/automateCLARK.py | CLARK.lists | def lists(self):
"""
Prepare the list of files to be processed
"""
# Prepare the lists to be used to classify the metagenomes
with open(self.filelist, 'w') as filelist:
with open(self.reportlist, 'w') as reportlist:
for sample in self.runmetadata.sampl... | python | def lists(self):
"""
Prepare the list of files to be processed
"""
# Prepare the lists to be used to classify the metagenomes
with open(self.filelist, 'w') as filelist:
with open(self.reportlist, 'w') as reportlist:
for sample in self.runmetadata.sampl... | [
"def",
"lists",
"(",
"self",
")",
":",
"with",
"open",
"(",
"self",
".",
"filelist",
",",
"'w'",
")",
"as",
"filelist",
":",
"with",
"open",
"(",
"self",
".",
"reportlist",
",",
"'w'",
")",
"as",
"reportlist",
":",
"for",
"sample",
"in",
"self",
".... | Prepare the list of files to be processed | [
"Prepare",
"the",
"list",
"of",
"files",
"to",
"be",
"processed"
] | 88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a | https://github.com/lowandrew/OLCTools/blob/88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a/metagenomefilter/automateCLARK.py#L105-L124 | train |
lowandrew/OLCTools | metagenomefilter/automateCLARK.py | CLARK.estimateabundance | def estimateabundance(self):
"""
Estimate the abundance of taxonomic groups
"""
logging.info('Estimating abundance of taxonomic groups')
# Create and start threads
for i in range(self.cpus):
# Send the threads to the appropriate destination function
... | python | def estimateabundance(self):
"""
Estimate the abundance of taxonomic groups
"""
logging.info('Estimating abundance of taxonomic groups')
# Create and start threads
for i in range(self.cpus):
# Send the threads to the appropriate destination function
... | [
"def",
"estimateabundance",
"(",
"self",
")",
":",
"logging",
".",
"info",
"(",
"'Estimating abundance of taxonomic groups'",
")",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"cpus",
")",
":",
"threads",
"=",
"Thread",
"(",
"target",
"=",
"self",
".",
"es... | Estimate the abundance of taxonomic groups | [
"Estimate",
"the",
"abundance",
"of",
"taxonomic",
"groups"
] | 88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a | https://github.com/lowandrew/OLCTools/blob/88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a/metagenomefilter/automateCLARK.py#L126-L160 | train |
TorkamaniLab/metapipe | metapipe/models/command_template_factory.py | get_command_templates | def get_command_templates(command_tokens, file_tokens=[], path_tokens=[],
job_options=[]):
""" Given a list of tokens from the grammar, return a
list of commands.
"""
files = get_files(file_tokens)
paths = get_paths(path_tokens)
job_options = get_options(job_options)
templates = _get_co... | python | def get_command_templates(command_tokens, file_tokens=[], path_tokens=[],
job_options=[]):
""" Given a list of tokens from the grammar, return a
list of commands.
"""
files = get_files(file_tokens)
paths = get_paths(path_tokens)
job_options = get_options(job_options)
templates = _get_co... | [
"def",
"get_command_templates",
"(",
"command_tokens",
",",
"file_tokens",
"=",
"[",
"]",
",",
"path_tokens",
"=",
"[",
"]",
",",
"job_options",
"=",
"[",
"]",
")",
":",
"files",
"=",
"get_files",
"(",
"file_tokens",
")",
"paths",
"=",
"get_paths",
"(",
... | Given a list of tokens from the grammar, return a
list of commands. | [
"Given",
"a",
"list",
"of",
"tokens",
"from",
"the",
"grammar",
"return",
"a",
"list",
"of",
"commands",
"."
] | 15592e5b0c217afb00ac03503f8d0d7453d4baf4 | https://github.com/TorkamaniLab/metapipe/blob/15592e5b0c217afb00ac03503f8d0d7453d4baf4/metapipe/models/command_template_factory.py#L15-L30 | train |
TorkamaniLab/metapipe | metapipe/models/command_template_factory.py | get_files | def get_files(file_tokens, cwd=None):
""" Given a list of parser file tokens, return a list of input objects
for them.
"""
if not file_tokens:
return []
token = file_tokens.pop()
try:
filename = token.filename
except AttributeError:
filename = ''
if cwd:
... | python | def get_files(file_tokens, cwd=None):
""" Given a list of parser file tokens, return a list of input objects
for them.
"""
if not file_tokens:
return []
token = file_tokens.pop()
try:
filename = token.filename
except AttributeError:
filename = ''
if cwd:
... | [
"def",
"get_files",
"(",
"file_tokens",
",",
"cwd",
"=",
"None",
")",
":",
"if",
"not",
"file_tokens",
":",
"return",
"[",
"]",
"token",
"=",
"file_tokens",
".",
"pop",
"(",
")",
"try",
":",
"filename",
"=",
"token",
".",
"filename",
"except",
"Attribu... | Given a list of parser file tokens, return a list of input objects
for them. | [
"Given",
"a",
"list",
"of",
"parser",
"file",
"tokens",
"return",
"a",
"list",
"of",
"input",
"objects",
"for",
"them",
"."
] | 15592e5b0c217afb00ac03503f8d0d7453d4baf4 | https://github.com/TorkamaniLab/metapipe/blob/15592e5b0c217afb00ac03503f8d0d7453d4baf4/metapipe/models/command_template_factory.py#L33-L51 | train |
TorkamaniLab/metapipe | metapipe/models/command_template_factory.py | get_paths | def get_paths(path_tokens):
""" Given a list of parser path tokens, return a list of path objects
for them.
"""
if len(path_tokens) == 0:
return []
token = path_tokens.pop()
path = PathToken(token.alias, token.path)
return [path] + get_paths(path_tokens) | python | def get_paths(path_tokens):
""" Given a list of parser path tokens, return a list of path objects
for them.
"""
if len(path_tokens) == 0:
return []
token = path_tokens.pop()
path = PathToken(token.alias, token.path)
return [path] + get_paths(path_tokens) | [
"def",
"get_paths",
"(",
"path_tokens",
")",
":",
"if",
"len",
"(",
"path_tokens",
")",
"==",
"0",
":",
"return",
"[",
"]",
"token",
"=",
"path_tokens",
".",
"pop",
"(",
")",
"path",
"=",
"PathToken",
"(",
"token",
".",
"alias",
",",
"token",
".",
... | Given a list of parser path tokens, return a list of path objects
for them. | [
"Given",
"a",
"list",
"of",
"parser",
"path",
"tokens",
"return",
"a",
"list",
"of",
"path",
"objects",
"for",
"them",
"."
] | 15592e5b0c217afb00ac03503f8d0d7453d4baf4 | https://github.com/TorkamaniLab/metapipe/blob/15592e5b0c217afb00ac03503f8d0d7453d4baf4/metapipe/models/command_template_factory.py#L54-L63 | train |
TorkamaniLab/metapipe | metapipe/models/command_template_factory.py | _get_command_templates | def _get_command_templates(command_tokens, files=[], paths=[], job_options=[],
count=1):
""" Reversivly create command templates. """
if not command_tokens:
return []
comment_tokens, command_token = command_tokens.pop()
parts = []
parts += job_options + _get_comments(comment_tokens)
... | python | def _get_command_templates(command_tokens, files=[], paths=[], job_options=[],
count=1):
""" Reversivly create command templates. """
if not command_tokens:
return []
comment_tokens, command_token = command_tokens.pop()
parts = []
parts += job_options + _get_comments(comment_tokens)
... | [
"def",
"_get_command_templates",
"(",
"command_tokens",
",",
"files",
"=",
"[",
"]",
",",
"paths",
"=",
"[",
"]",
",",
"job_options",
"=",
"[",
"]",
",",
"count",
"=",
"1",
")",
":",
"if",
"not",
"command_tokens",
":",
"return",
"[",
"]",
"comment_toke... | Reversivly create command templates. | [
"Reversivly",
"create",
"command",
"templates",
"."
] | 15592e5b0c217afb00ac03503f8d0d7453d4baf4 | https://github.com/TorkamaniLab/metapipe/blob/15592e5b0c217afb00ac03503f8d0d7453d4baf4/metapipe/models/command_template_factory.py#L74-L106 | train |
TorkamaniLab/metapipe | metapipe/models/command_template_factory.py | _get_prelim_dependencies | def _get_prelim_dependencies(command_template, all_templates):
""" Given a command_template determine which other templates it
depends on. This should not be used as the be-all end-all of
dependencies and before calling each command, ensure that it's
requirements are met.
"""
deps = []
for ... | python | def _get_prelim_dependencies(command_template, all_templates):
""" Given a command_template determine which other templates it
depends on. This should not be used as the be-all end-all of
dependencies and before calling each command, ensure that it's
requirements are met.
"""
deps = []
for ... | [
"def",
"_get_prelim_dependencies",
"(",
"command_template",
",",
"all_templates",
")",
":",
"deps",
"=",
"[",
"]",
"for",
"input",
"in",
"command_template",
".",
"input_parts",
":",
"if",
"'.'",
"not",
"in",
"input",
".",
"alias",
":",
"continue",
"for",
"te... | Given a command_template determine which other templates it
depends on. This should not be used as the be-all end-all of
dependencies and before calling each command, ensure that it's
requirements are met. | [
"Given",
"a",
"command_template",
"determine",
"which",
"other",
"templates",
"it",
"depends",
"on",
".",
"This",
"should",
"not",
"be",
"used",
"as",
"the",
"be",
"-",
"all",
"end",
"-",
"all",
"of",
"dependencies",
"and",
"before",
"calling",
"each",
"co... | 15592e5b0c217afb00ac03503f8d0d7453d4baf4 | https://github.com/TorkamaniLab/metapipe/blob/15592e5b0c217afb00ac03503f8d0d7453d4baf4/metapipe/models/command_template_factory.py#L109-L124 | train |
TorkamaniLab/metapipe | metapipe/models/command_template_factory.py | _is_output | def _is_output(part):
""" Returns whether the given part represents an output variable. """
if part[0].lower() == 'o':
return True
elif part[0][:2].lower() == 'o:':
return True
elif part[0][:2].lower() == 'o.':
return True
else:
return False | python | def _is_output(part):
""" Returns whether the given part represents an output variable. """
if part[0].lower() == 'o':
return True
elif part[0][:2].lower() == 'o:':
return True
elif part[0][:2].lower() == 'o.':
return True
else:
return False | [
"def",
"_is_output",
"(",
"part",
")",
":",
"if",
"part",
"[",
"0",
"]",
".",
"lower",
"(",
")",
"==",
"'o'",
":",
"return",
"True",
"elif",
"part",
"[",
"0",
"]",
"[",
":",
"2",
"]",
".",
"lower",
"(",
")",
"==",
"'o:'",
":",
"return",
"True... | Returns whether the given part represents an output variable. | [
"Returns",
"whether",
"the",
"given",
"part",
"represents",
"an",
"output",
"variable",
"."
] | 15592e5b0c217afb00ac03503f8d0d7453d4baf4 | https://github.com/TorkamaniLab/metapipe/blob/15592e5b0c217afb00ac03503f8d0d7453d4baf4/metapipe/models/command_template_factory.py#L182-L191 | train |
RedHatQE/Sentaku | examples/mini_example.py | search_browser | def search_browser(self, text):
"""do a slow search via the website and return the first match"""
self.impl.get(self.base_url)
search_div = self.impl.find_element_by_id("search")
search_term = search_div.find_element_by_id("term")
search_term.send_keys(text)
search_div.find_element_by_id("submi... | python | def search_browser(self, text):
"""do a slow search via the website and return the first match"""
self.impl.get(self.base_url)
search_div = self.impl.find_element_by_id("search")
search_term = search_div.find_element_by_id("term")
search_term.send_keys(text)
search_div.find_element_by_id("submi... | [
"def",
"search_browser",
"(",
"self",
",",
"text",
")",
":",
"self",
".",
"impl",
".",
"get",
"(",
"self",
".",
"base_url",
")",
"search_div",
"=",
"self",
".",
"impl",
".",
"find_element_by_id",
"(",
"\"search\"",
")",
"search_term",
"=",
"search_div",
... | do a slow search via the website and return the first match | [
"do",
"a",
"slow",
"search",
"via",
"the",
"website",
"and",
"return",
"the",
"first",
"match"
] | b336cef5b6ee2db4e8dff28dcdb2be35a1f3d01c | https://github.com/RedHatQE/Sentaku/blob/b336cef5b6ee2db4e8dff28dcdb2be35a1f3d01c/examples/mini_example.py#L51-L60 | train |
RedHatQE/Sentaku | examples/mini_example.py | search_fast | def search_fast(self, text):
"""do a sloppy quick "search" via the json index"""
resp = self.impl.get(
"{base_url}/{text}/json".format(base_url=self.base_url, text=text)
)
return resp.json()["info"]["package_url"] | python | def search_fast(self, text):
"""do a sloppy quick "search" via the json index"""
resp = self.impl.get(
"{base_url}/{text}/json".format(base_url=self.base_url, text=text)
)
return resp.json()["info"]["package_url"] | [
"def",
"search_fast",
"(",
"self",
",",
"text",
")",
":",
"resp",
"=",
"self",
".",
"impl",
".",
"get",
"(",
"\"{base_url}/{text}/json\"",
".",
"format",
"(",
"base_url",
"=",
"self",
".",
"base_url",
",",
"text",
"=",
"text",
")",
")",
"return",
"resp... | do a sloppy quick "search" via the json index | [
"do",
"a",
"sloppy",
"quick",
"search",
"via",
"the",
"json",
"index"
] | b336cef5b6ee2db4e8dff28dcdb2be35a1f3d01c | https://github.com/RedHatQE/Sentaku/blob/b336cef5b6ee2db4e8dff28dcdb2be35a1f3d01c/examples/mini_example.py#L64-L70 | train |
RedHatQE/Sentaku | examples/mini_example.py | main | def main(search, query):
"""main function that does the search"""
url = search.search(query)
print(url)
search.open_page(url) | python | def main(search, query):
"""main function that does the search"""
url = search.search(query)
print(url)
search.open_page(url) | [
"def",
"main",
"(",
"search",
",",
"query",
")",
":",
"url",
"=",
"search",
".",
"search",
"(",
"query",
")",
"print",
"(",
"url",
")",
"search",
".",
"open_page",
"(",
"url",
")"
] | main function that does the search | [
"main",
"function",
"that",
"does",
"the",
"search"
] | b336cef5b6ee2db4e8dff28dcdb2be35a1f3d01c | https://github.com/RedHatQE/Sentaku/blob/b336cef5b6ee2db4e8dff28dcdb2be35a1f3d01c/examples/mini_example.py#L78-L82 | train |
RedHatQE/Sentaku | examples/mini_example.py | cli_main | def cli_main():
"""cli entrypoitns, sets up everything needed"""
SearchContext.commit()
args = parser.parse_args()
# open up a browser
firefox_remote = Remote("http://127.0.0.1:4444/wd/hub", DesiredCapabilities.FIREFOX)
with contextlib.closing(firefox_remote):
context = SearchContext.fro... | python | def cli_main():
"""cli entrypoitns, sets up everything needed"""
SearchContext.commit()
args = parser.parse_args()
# open up a browser
firefox_remote = Remote("http://127.0.0.1:4444/wd/hub", DesiredCapabilities.FIREFOX)
with contextlib.closing(firefox_remote):
context = SearchContext.fro... | [
"def",
"cli_main",
"(",
")",
":",
"SearchContext",
".",
"commit",
"(",
")",
"args",
"=",
"parser",
".",
"parse_args",
"(",
")",
"firefox_remote",
"=",
"Remote",
"(",
"\"http://127.0.0.1:4444/wd/hub\"",
",",
"DesiredCapabilities",
".",
"FIREFOX",
")",
"with",
"... | cli entrypoitns, sets up everything needed | [
"cli",
"entrypoitns",
"sets",
"up",
"everything",
"needed"
] | b336cef5b6ee2db4e8dff28dcdb2be35a1f3d01c | https://github.com/RedHatQE/Sentaku/blob/b336cef5b6ee2db4e8dff28dcdb2be35a1f3d01c/examples/mini_example.py#L85-L100 | train |
wylee/runcommands | runcommands/util/string.py | camel_to_underscore | def camel_to_underscore(name):
"""Convert camel case name to underscore name.
Examples::
>>> camel_to_underscore('HttpRequest')
'http_request'
>>> camel_to_underscore('httpRequest')
'http_request'
>>> camel_to_underscore('HTTPRequest')
'http_request'
>>>... | python | def camel_to_underscore(name):
"""Convert camel case name to underscore name.
Examples::
>>> camel_to_underscore('HttpRequest')
'http_request'
>>> camel_to_underscore('httpRequest')
'http_request'
>>> camel_to_underscore('HTTPRequest')
'http_request'
>>>... | [
"def",
"camel_to_underscore",
"(",
"name",
")",
":",
"name",
"=",
"re",
".",
"sub",
"(",
"r'(?<!\\b)(?<!_)([A-Z][a-z])'",
",",
"r'_\\1'",
",",
"name",
")",
"name",
"=",
"re",
".",
"sub",
"(",
"r'(?<!\\b)(?<!_)([a-z])([A-Z])'",
",",
"r'\\1_\\2'",
",",
"name",
... | Convert camel case name to underscore name.
Examples::
>>> camel_to_underscore('HttpRequest')
'http_request'
>>> camel_to_underscore('httpRequest')
'http_request'
>>> camel_to_underscore('HTTPRequest')
'http_request'
>>> camel_to_underscore('myHTTPRequest')
... | [
"Convert",
"camel",
"case",
"name",
"to",
"underscore",
"name",
"."
] | b1d7c262885b9ced7ab89b63562f5464ca9970fe | https://github.com/wylee/runcommands/blob/b1d7c262885b9ced7ab89b63562f5464ca9970fe/runcommands/util/string.py#L4-L42 | train |
JukeboxPipeline/jukeboxmaya | src/jukeboxmaya/launcher.py | main_func | def main_func(args=None):
"""Main funcion when executing this module as script
:param args: commandline arguments
:type args: list
:returns: None
:rtype: None
:raises: None
"""
# we have to initialize a gui even if we dont need one right now.
# as soon as you call maya.standalone.in... | python | def main_func(args=None):
"""Main funcion when executing this module as script
:param args: commandline arguments
:type args: list
:returns: None
:rtype: None
:raises: None
"""
# we have to initialize a gui even if we dont need one right now.
# as soon as you call maya.standalone.in... | [
"def",
"main_func",
"(",
"args",
"=",
"None",
")",
":",
"guimain",
".",
"init_gui",
"(",
")",
"main",
".",
"init",
"(",
")",
"launcher",
"=",
"Launcher",
"(",
")",
"parsed",
",",
"unknown",
"=",
"launcher",
".",
"parse_args",
"(",
"args",
")",
"parse... | Main funcion when executing this module as script
:param args: commandline arguments
:type args: list
:returns: None
:rtype: None
:raises: None | [
"Main",
"funcion",
"when",
"executing",
"this",
"module",
"as",
"script"
] | c8d6318d53cdb5493453c4a6b65ef75bdb2d5f2c | https://github.com/JukeboxPipeline/jukeboxmaya/blob/c8d6318d53cdb5493453c4a6b65ef75bdb2d5f2c/src/jukeboxmaya/launcher.py#L143-L161 | train |
JukeboxPipeline/jukeboxmaya | src/jukeboxmaya/launcher.py | Launcher.setup_launch_parser | def setup_launch_parser(self, parser):
"""Setup the given parser for the launch command
:param parser: the argument parser to setup
:type parser: :class:`argparse.ArgumentParser`
:returns: None
:rtype: None
:raises: None
"""
parser.set_defaults(func=self.... | python | def setup_launch_parser(self, parser):
"""Setup the given parser for the launch command
:param parser: the argument parser to setup
:type parser: :class:`argparse.ArgumentParser`
:returns: None
:rtype: None
:raises: None
"""
parser.set_defaults(func=self.... | [
"def",
"setup_launch_parser",
"(",
"self",
",",
"parser",
")",
":",
"parser",
".",
"set_defaults",
"(",
"func",
"=",
"self",
".",
"launch",
")",
"parser",
".",
"add_argument",
"(",
"\"addon\"",
",",
"help",
"=",
"\"The jukebox addon to launch. The addon should be ... | Setup the given parser for the launch command
:param parser: the argument parser to setup
:type parser: :class:`argparse.ArgumentParser`
:returns: None
:rtype: None
:raises: None | [
"Setup",
"the",
"given",
"parser",
"for",
"the",
"launch",
"command"
] | c8d6318d53cdb5493453c4a6b65ef75bdb2d5f2c | https://github.com/JukeboxPipeline/jukeboxmaya/blob/c8d6318d53cdb5493453c4a6b65ef75bdb2d5f2c/src/jukeboxmaya/launcher.py#L58-L68 | train |
JukeboxPipeline/jukeboxmaya | src/jukeboxmaya/launcher.py | Launcher.parse_args | def parse_args(self, args=None):
"""Parse the given arguments
All commands should support executing a function,
so you can use the arg Namespace like this::
launcher = Launcher()
args, unknown = launcher.parse_args()
args.func(args, unknown) # execute the command
... | python | def parse_args(self, args=None):
"""Parse the given arguments
All commands should support executing a function,
so you can use the arg Namespace like this::
launcher = Launcher()
args, unknown = launcher.parse_args()
args.func(args, unknown) # execute the command
... | [
"def",
"parse_args",
"(",
"self",
",",
"args",
"=",
"None",
")",
":",
"if",
"args",
"is",
"None",
":",
"args",
"=",
"sys",
".",
"argv",
"[",
"1",
":",
"]",
"return",
"self",
".",
"parser",
".",
"parse_known_args",
"(",
"args",
")"
] | Parse the given arguments
All commands should support executing a function,
so you can use the arg Namespace like this::
launcher = Launcher()
args, unknown = launcher.parse_args()
args.func(args, unknown) # execute the command
:param args: arguments to pass
... | [
"Parse",
"the",
"given",
"arguments"
] | c8d6318d53cdb5493453c4a6b65ef75bdb2d5f2c | https://github.com/JukeboxPipeline/jukeboxmaya/blob/c8d6318d53cdb5493453c4a6b65ef75bdb2d5f2c/src/jukeboxmaya/launcher.py#L122-L140 | train |
yamcs/yamcs-python | yamcs-client/yamcs/storage/model.py | Bucket.list_objects | def list_objects(self, prefix=None, delimiter=None):
"""
List the objects for this bucket.
:param str prefix: If specified, only objects that start with this
prefix are listed.
:param str delimiter: If specified, return only objects whose name
... | python | def list_objects(self, prefix=None, delimiter=None):
"""
List the objects for this bucket.
:param str prefix: If specified, only objects that start with this
prefix are listed.
:param str delimiter: If specified, return only objects whose name
... | [
"def",
"list_objects",
"(",
"self",
",",
"prefix",
"=",
"None",
",",
"delimiter",
"=",
"None",
")",
":",
"return",
"self",
".",
"_client",
".",
"list_objects",
"(",
"instance",
"=",
"self",
".",
"_instance",
",",
"bucket_name",
"=",
"self",
".",
"name",
... | List the objects for this bucket.
:param str prefix: If specified, only objects that start with this
prefix are listed.
:param str delimiter: If specified, return only objects whose name
do not contain the delimiter after the prefix.
... | [
"List",
"the",
"objects",
"for",
"this",
"bucket",
"."
] | 1082fee8a299010cc44416bbb7518fac0ef08b48 | https://github.com/yamcs/yamcs-python/blob/1082fee8a299010cc44416bbb7518fac0ef08b48/yamcs-client/yamcs/storage/model.py#L26-L41 | train |
yamcs/yamcs-python | yamcs-client/yamcs/storage/model.py | Bucket.upload_object | def upload_object(self, object_name, file_obj):
"""
Upload an object to this bucket.
:param str object_name: The target name of the object.
:param file file_obj: The file (or file-like object) to upload.
:param str content_type: The content type associated to this object.
... | python | def upload_object(self, object_name, file_obj):
"""
Upload an object to this bucket.
:param str object_name: The target name of the object.
:param file file_obj: The file (or file-like object) to upload.
:param str content_type: The content type associated to this object.
... | [
"def",
"upload_object",
"(",
"self",
",",
"object_name",
",",
"file_obj",
")",
":",
"return",
"self",
".",
"_client",
".",
"upload_object",
"(",
"self",
".",
"_instance",
",",
"self",
".",
"name",
",",
"object_name",
",",
"file_obj",
")"
] | Upload an object to this bucket.
:param str object_name: The target name of the object.
:param file file_obj: The file (or file-like object) to upload.
:param str content_type: The content type associated to this object.
This is mainly useful when accessing an o... | [
"Upload",
"an",
"object",
"to",
"this",
"bucket",
"."
] | 1082fee8a299010cc44416bbb7518fac0ef08b48 | https://github.com/yamcs/yamcs-python/blob/1082fee8a299010cc44416bbb7518fac0ef08b48/yamcs-client/yamcs/storage/model.py#L52-L65 | train |
yamcs/yamcs-python | yamcs-client/yamcs/storage/model.py | Bucket.delete_object | def delete_object(self, object_name):
"""
Remove an object from this bucket.
:param str object_name: The object to remove.
"""
self._client.remove_object(self._instance, self.name, object_name) | python | def delete_object(self, object_name):
"""
Remove an object from this bucket.
:param str object_name: The object to remove.
"""
self._client.remove_object(self._instance, self.name, object_name) | [
"def",
"delete_object",
"(",
"self",
",",
"object_name",
")",
":",
"self",
".",
"_client",
".",
"remove_object",
"(",
"self",
".",
"_instance",
",",
"self",
".",
"name",
",",
"object_name",
")"
] | Remove an object from this bucket.
:param str object_name: The object to remove. | [
"Remove",
"an",
"object",
"from",
"this",
"bucket",
"."
] | 1082fee8a299010cc44416bbb7518fac0ef08b48 | https://github.com/yamcs/yamcs-python/blob/1082fee8a299010cc44416bbb7518fac0ef08b48/yamcs-client/yamcs/storage/model.py#L67-L73 | train |
yamcs/yamcs-python | yamcs-client/yamcs/storage/model.py | ObjectListing.objects | def objects(self):
"""
The objects in this listing.
:type: List[:class:`.ObjectInfo`]
"""
return [ObjectInfo(o, self._instance, self._bucket, self._client)
for o in self._proto.object] | python | def objects(self):
"""
The objects in this listing.
:type: List[:class:`.ObjectInfo`]
"""
return [ObjectInfo(o, self._instance, self._bucket, self._client)
for o in self._proto.object] | [
"def",
"objects",
"(",
"self",
")",
":",
"return",
"[",
"ObjectInfo",
"(",
"o",
",",
"self",
".",
"_instance",
",",
"self",
".",
"_bucket",
",",
"self",
".",
"_client",
")",
"for",
"o",
"in",
"self",
".",
"_proto",
".",
"object",
"]"
] | The objects in this listing.
:type: List[:class:`.ObjectInfo`] | [
"The",
"objects",
"in",
"this",
"listing",
"."
] | 1082fee8a299010cc44416bbb7518fac0ef08b48 | https://github.com/yamcs/yamcs-python/blob/1082fee8a299010cc44416bbb7518fac0ef08b48/yamcs-client/yamcs/storage/model.py#L103-L110 | train |
yamcs/yamcs-python | yamcs-client/yamcs/storage/model.py | ObjectInfo.delete | def delete(self):
"""Remove this object."""
self._client.remove_object(self._instance, self._bucket, self.name) | python | def delete(self):
"""Remove this object."""
self._client.remove_object(self._instance, self._bucket, self.name) | [
"def",
"delete",
"(",
"self",
")",
":",
"self",
".",
"_client",
".",
"remove_object",
"(",
"self",
".",
"_instance",
",",
"self",
".",
"_bucket",
",",
"self",
".",
"name",
")"
] | Remove this object. | [
"Remove",
"this",
"object",
"."
] | 1082fee8a299010cc44416bbb7518fac0ef08b48 | https://github.com/yamcs/yamcs-python/blob/1082fee8a299010cc44416bbb7518fac0ef08b48/yamcs-client/yamcs/storage/model.py#L142-L144 | train |
yamcs/yamcs-python | yamcs-client/yamcs/storage/model.py | ObjectInfo.download | def download(self):
"""Download this object."""
return self._client.download_object(
self._instance, self._bucket, self.name) | python | def download(self):
"""Download this object."""
return self._client.download_object(
self._instance, self._bucket, self.name) | [
"def",
"download",
"(",
"self",
")",
":",
"return",
"self",
".",
"_client",
".",
"download_object",
"(",
"self",
".",
"_instance",
",",
"self",
".",
"_bucket",
",",
"self",
".",
"name",
")"
] | Download this object. | [
"Download",
"this",
"object",
"."
] | 1082fee8a299010cc44416bbb7518fac0ef08b48 | https://github.com/yamcs/yamcs-python/blob/1082fee8a299010cc44416bbb7518fac0ef08b48/yamcs-client/yamcs/storage/model.py#L146-L149 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.