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
listlengths
20
707
docstring
stringlengths
3
17.3k
docstring_tokens
listlengths
3
222
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
idx
int64
0
252k
hatemile/hatemile-for-python
hatemile/util/idgenerator.py
IDGenerator.generate_id
def generate_id(self, element): """ Generate a id for a element. :param element: The element. :type element: hatemile.util.html.HTMLDOMElement """ if not element.has_attribute('id'): element.set_attribute('id', self.prefix_id + str(self.count)) s...
python
def generate_id(self, element): """ Generate a id for a element. :param element: The element. :type element: hatemile.util.html.HTMLDOMElement """ if not element.has_attribute('id'): element.set_attribute('id', self.prefix_id + str(self.count)) s...
[ "def", "generate_id", "(", "self", ",", "element", ")", ":", "if", "not", "element", ".", "has_attribute", "(", "'id'", ")", ":", "element", ".", "set_attribute", "(", "'id'", ",", "self", ".", "prefix_id", "+", "str", "(", "self", ".", "count", ")", ...
Generate a id for a element. :param element: The element. :type element: hatemile.util.html.HTMLDOMElement
[ "Generate", "a", "id", "for", "a", "element", "." ]
1e914f9aa09f6f8d78282af131311546ecba9fb8
https://github.com/hatemile/hatemile-for-python/blob/1e914f9aa09f6f8d78282af131311546ecba9fb8/hatemile/util/idgenerator.py#L60-L70
train
58,600
The-Politico/politico-civic-demography
demography/management/commands/bootstrap/fetch/__init__.py
Fetcher.fetch_state_data
def fetch_state_data(self, states): """ Fetch census estimates from table. """ print("Fetching census data") for table in CensusTable.objects.all(): api = self.get_series(table.series) for variable in table.variables.all(): estimate = "{}_{...
python
def fetch_state_data(self, states): """ Fetch census estimates from table. """ print("Fetching census data") for table in CensusTable.objects.all(): api = self.get_series(table.series) for variable in table.variables.all(): estimate = "{}_{...
[ "def", "fetch_state_data", "(", "self", ",", "states", ")", ":", "print", "(", "\"Fetching census data\"", ")", "for", "table", "in", "CensusTable", ".", "objects", ".", "all", "(", ")", ":", "api", "=", "self", ".", "get_series", "(", "table", ".", "ser...
Fetch census estimates from table.
[ "Fetch", "census", "estimates", "from", "table", "." ]
080bb964b64b06db7fd04386530e893ceed1cf98
https://github.com/The-Politico/politico-civic-demography/blob/080bb964b64b06db7fd04386530e893ceed1cf98/demography/management/commands/bootstrap/fetch/__init__.py#L20-L55
train
58,601
panyam/typecube
typecube/annotations.py
Annotations.has
def has(self, name): """ Returns True if there is atleast one annotation by a given name, otherwise False. """ for a in self.all_annotations: if a.name == name: return True return False
python
def has(self, name): """ Returns True if there is atleast one annotation by a given name, otherwise False. """ for a in self.all_annotations: if a.name == name: return True return False
[ "def", "has", "(", "self", ",", "name", ")", ":", "for", "a", "in", "self", ".", "all_annotations", ":", "if", "a", ".", "name", "==", "name", ":", "return", "True", "return", "False" ]
Returns True if there is atleast one annotation by a given name, otherwise False.
[ "Returns", "True", "if", "there", "is", "atleast", "one", "annotation", "by", "a", "given", "name", "otherwise", "False", "." ]
e8fa235675b6497acd52c68286bb9e4aefc5c8d1
https://github.com/panyam/typecube/blob/e8fa235675b6497acd52c68286bb9e4aefc5c8d1/typecube/annotations.py#L57-L64
train
58,602
panyam/typecube
typecube/annotations.py
Annotations.get_first
def get_first(self, name): """ Get the first annotation by a given name. """ for a in self.all_annotations: if a.name == name: return a return None
python
def get_first(self, name): """ Get the first annotation by a given name. """ for a in self.all_annotations: if a.name == name: return a return None
[ "def", "get_first", "(", "self", ",", "name", ")", ":", "for", "a", "in", "self", ".", "all_annotations", ":", "if", "a", ".", "name", "==", "name", ":", "return", "a", "return", "None" ]
Get the first annotation by a given name.
[ "Get", "the", "first", "annotation", "by", "a", "given", "name", "." ]
e8fa235675b6497acd52c68286bb9e4aefc5c8d1
https://github.com/panyam/typecube/blob/e8fa235675b6497acd52c68286bb9e4aefc5c8d1/typecube/annotations.py#L66-L73
train
58,603
panyam/typecube
typecube/annotations.py
Annotations.get_all
def get_all(self, name): """ Get all the annotation by a given name. """ return [annot for annot in self.all_annotations if annot.name == name]
python
def get_all(self, name): """ Get all the annotation by a given name. """ return [annot for annot in self.all_annotations if annot.name == name]
[ "def", "get_all", "(", "self", ",", "name", ")", ":", "return", "[", "annot", "for", "annot", "in", "self", ".", "all_annotations", "if", "annot", ".", "name", "==", "name", "]" ]
Get all the annotation by a given name.
[ "Get", "all", "the", "annotation", "by", "a", "given", "name", "." ]
e8fa235675b6497acd52c68286bb9e4aefc5c8d1
https://github.com/panyam/typecube/blob/e8fa235675b6497acd52c68286bb9e4aefc5c8d1/typecube/annotations.py#L75-L79
train
58,604
panyam/typecube
typecube/annotations.py
Annotation.first_value_of
def first_value_of(self, name, default_value = None): """ Return the first value of a particular param by name if it exists otherwise false. """ vals = self.values_of(name) if vals is not None: return vals if type(vals) is not list else vals[0] return default_...
python
def first_value_of(self, name, default_value = None): """ Return the first value of a particular param by name if it exists otherwise false. """ vals = self.values_of(name) if vals is not None: return vals if type(vals) is not list else vals[0] return default_...
[ "def", "first_value_of", "(", "self", ",", "name", ",", "default_value", "=", "None", ")", ":", "vals", "=", "self", ".", "values_of", "(", "name", ")", "if", "vals", "is", "not", "None", ":", "return", "vals", "if", "type", "(", "vals", ")", "is", ...
Return the first value of a particular param by name if it exists otherwise false.
[ "Return", "the", "first", "value", "of", "a", "particular", "param", "by", "name", "if", "it", "exists", "otherwise", "false", "." ]
e8fa235675b6497acd52c68286bb9e4aefc5c8d1
https://github.com/panyam/typecube/blob/e8fa235675b6497acd52c68286bb9e4aefc5c8d1/typecube/annotations.py#L127-L134
train
58,605
hatemile/hatemile-for-python
setup.py
get_long_description
def get_long_description(): """ Returns the long description of HaTeMiLe for Python. :return: The long description of HaTeMiLe for Python. :rtype: str """ with open( os.path.join(BASE_DIRECTORY, 'README.md'), 'r', encoding='utf-8' ) as readme_file: return re...
python
def get_long_description(): """ Returns the long description of HaTeMiLe for Python. :return: The long description of HaTeMiLe for Python. :rtype: str """ with open( os.path.join(BASE_DIRECTORY, 'README.md'), 'r', encoding='utf-8' ) as readme_file: return re...
[ "def", "get_long_description", "(", ")", ":", "with", "open", "(", "os", ".", "path", ".", "join", "(", "BASE_DIRECTORY", ",", "'README.md'", ")", ",", "'r'", ",", "encoding", "=", "'utf-8'", ")", "as", "readme_file", ":", "return", "readme_file", ".", "...
Returns the long description of HaTeMiLe for Python. :return: The long description of HaTeMiLe for Python. :rtype: str
[ "Returns", "the", "long", "description", "of", "HaTeMiLe", "for", "Python", "." ]
1e914f9aa09f6f8d78282af131311546ecba9fb8
https://github.com/hatemile/hatemile-for-python/blob/1e914f9aa09f6f8d78282af131311546ecba9fb8/setup.py#L26-L39
train
58,606
hatemile/hatemile-for-python
setup.py
get_packages
def get_packages(): """ Returns the packages used for HaTeMiLe for Python. :return: The packages used for HaTeMiLe for Python. :rtype: list(str) """ packages = find_packages(exclude=['tests']) packages.append('') packages.append('js') packages.append(LOCALES_DIRECTORY) for dir...
python
def get_packages(): """ Returns the packages used for HaTeMiLe for Python. :return: The packages used for HaTeMiLe for Python. :rtype: list(str) """ packages = find_packages(exclude=['tests']) packages.append('') packages.append('js') packages.append(LOCALES_DIRECTORY) for dir...
[ "def", "get_packages", "(", ")", ":", "packages", "=", "find_packages", "(", "exclude", "=", "[", "'tests'", "]", ")", "packages", ".", "append", "(", "''", ")", "packages", ".", "append", "(", "'js'", ")", "packages", ".", "append", "(", "LOCALES_DIRECT...
Returns the packages used for HaTeMiLe for Python. :return: The packages used for HaTeMiLe for Python. :rtype: list(str)
[ "Returns", "the", "packages", "used", "for", "HaTeMiLe", "for", "Python", "." ]
1e914f9aa09f6f8d78282af131311546ecba9fb8
https://github.com/hatemile/hatemile-for-python/blob/1e914f9aa09f6f8d78282af131311546ecba9fb8/setup.py#L42-L57
train
58,607
hatemile/hatemile-for-python
setup.py
get_package_data
def get_package_data(): """ Returns the packages with static files of HaTeMiLe for Python. :return: The packages with static files of HaTeMiLe for Python. :rtype: dict(str, list(str)) """ package_data = { '': ['*.xml'], 'js': ['*.js'], LOCALES_DIRECTORY: ['*'] } ...
python
def get_package_data(): """ Returns the packages with static files of HaTeMiLe for Python. :return: The packages with static files of HaTeMiLe for Python. :rtype: dict(str, list(str)) """ package_data = { '': ['*.xml'], 'js': ['*.js'], LOCALES_DIRECTORY: ['*'] } ...
[ "def", "get_package_data", "(", ")", ":", "package_data", "=", "{", "''", ":", "[", "'*.xml'", "]", ",", "'js'", ":", "[", "'*.js'", "]", ",", "LOCALES_DIRECTORY", ":", "[", "'*'", "]", "}", "for", "directory", "in", "os", ".", "listdir", "(", "LOCAL...
Returns the packages with static files of HaTeMiLe for Python. :return: The packages with static files of HaTeMiLe for Python. :rtype: dict(str, list(str))
[ "Returns", "the", "packages", "with", "static", "files", "of", "HaTeMiLe", "for", "Python", "." ]
1e914f9aa09f6f8d78282af131311546ecba9fb8
https://github.com/hatemile/hatemile-for-python/blob/1e914f9aa09f6f8d78282af131311546ecba9fb8/setup.py#L60-L76
train
58,608
hatemile/hatemile-for-python
setup.py
get_requirements
def get_requirements(): """ Returns the content of 'requirements.txt' in a list. :return: The content of 'requirements.txt'. :rtype: list(str) """ requirements = [] with open( os.path.join(BASE_DIRECTORY, 'requirements.txt'), 'r', encoding='utf-8' ) as requireme...
python
def get_requirements(): """ Returns the content of 'requirements.txt' in a list. :return: The content of 'requirements.txt'. :rtype: list(str) """ requirements = [] with open( os.path.join(BASE_DIRECTORY, 'requirements.txt'), 'r', encoding='utf-8' ) as requireme...
[ "def", "get_requirements", "(", ")", ":", "requirements", "=", "[", "]", "with", "open", "(", "os", ".", "path", ".", "join", "(", "BASE_DIRECTORY", ",", "'requirements.txt'", ")", ",", "'r'", ",", "encoding", "=", "'utf-8'", ")", "as", "requirements_file"...
Returns the content of 'requirements.txt' in a list. :return: The content of 'requirements.txt'. :rtype: list(str)
[ "Returns", "the", "content", "of", "requirements", ".", "txt", "in", "a", "list", "." ]
1e914f9aa09f6f8d78282af131311546ecba9fb8
https://github.com/hatemile/hatemile-for-python/blob/1e914f9aa09f6f8d78282af131311546ecba9fb8/setup.py#L79-L96
train
58,609
AtomHash/evernode
evernode/models/session_model.py
SessionModel.where_session_id
def where_session_id(cls, session_id): """ Easy way to query by session id """ try: session = cls.query.filter_by(session_id=session_id).one() return session except (NoResultFound, MultipleResultsFound): return None
python
def where_session_id(cls, session_id): """ Easy way to query by session id """ try: session = cls.query.filter_by(session_id=session_id).one() return session except (NoResultFound, MultipleResultsFound): return None
[ "def", "where_session_id", "(", "cls", ",", "session_id", ")", ":", "try", ":", "session", "=", "cls", ".", "query", ".", "filter_by", "(", "session_id", "=", "session_id", ")", ".", "one", "(", ")", "return", "session", "except", "(", "NoResultFound", "...
Easy way to query by session id
[ "Easy", "way", "to", "query", "by", "session", "id" ]
b2fb91555fb937a3f3eba41db56dee26f9b034be
https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/models/session_model.py#L14-L20
train
58,610
AtomHash/evernode
evernode/models/session_model.py
SessionModel.count
def count(cls, user_id): """ Count sessions with user_id """ return cls.query.with_entities( cls.user_id).filter_by(user_id=user_id).count()
python
def count(cls, user_id): """ Count sessions with user_id """ return cls.query.with_entities( cls.user_id).filter_by(user_id=user_id).count()
[ "def", "count", "(", "cls", ",", "user_id", ")", ":", "return", "cls", ".", "query", ".", "with_entities", "(", "cls", ".", "user_id", ")", ".", "filter_by", "(", "user_id", "=", "user_id", ")", ".", "count", "(", ")" ]
Count sessions with user_id
[ "Count", "sessions", "with", "user_id" ]
b2fb91555fb937a3f3eba41db56dee26f9b034be
https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/models/session_model.py#L40-L43
train
58,611
VJftw/invoke-tools
idflow/utils.py
Utils.get_branch
def get_branch(): """ Returns the current code branch """ if os.getenv('GIT_BRANCH'): # Travis branch = os.getenv('GIT_BRANCH') elif os.getenv('BRANCH_NAME'): # Jenkins 2 branch = os.getenv('BRANCH_NAME') else: b...
python
def get_branch(): """ Returns the current code branch """ if os.getenv('GIT_BRANCH'): # Travis branch = os.getenv('GIT_BRANCH') elif os.getenv('BRANCH_NAME'): # Jenkins 2 branch = os.getenv('BRANCH_NAME') else: b...
[ "def", "get_branch", "(", ")", ":", "if", "os", ".", "getenv", "(", "'GIT_BRANCH'", ")", ":", "# Travis", "branch", "=", "os", ".", "getenv", "(", "'GIT_BRANCH'", ")", "elif", "os", ".", "getenv", "(", "'BRANCH_NAME'", ")", ":", "# Jenkins 2", "branch", ...
Returns the current code branch
[ "Returns", "the", "current", "code", "branch" ]
9584a1f8a402118310b6f2a495062f388fc8dc3a
https://github.com/VJftw/invoke-tools/blob/9584a1f8a402118310b6f2a495062f388fc8dc3a/idflow/utils.py#L19-L34
train
58,612
VJftw/invoke-tools
idflow/utils.py
Utils.get_version
def get_version(): """ Returns the current code version """ try: return check_output( "git describe --tags".split(" ") ).decode('utf-8').strip() except CalledProcessError: return check_output( "git rev-parse ...
python
def get_version(): """ Returns the current code version """ try: return check_output( "git describe --tags".split(" ") ).decode('utf-8').strip() except CalledProcessError: return check_output( "git rev-parse ...
[ "def", "get_version", "(", ")", ":", "try", ":", "return", "check_output", "(", "\"git describe --tags\"", ".", "split", "(", "\" \"", ")", ")", ".", "decode", "(", "'utf-8'", ")", ".", "strip", "(", ")", "except", "CalledProcessError", ":", "return", "che...
Returns the current code version
[ "Returns", "the", "current", "code", "version" ]
9584a1f8a402118310b6f2a495062f388fc8dc3a
https://github.com/VJftw/invoke-tools/blob/9584a1f8a402118310b6f2a495062f388fc8dc3a/idflow/utils.py#L37-L48
train
58,613
VJftw/invoke-tools
idflow/utils.py
Utils.jenkins_last_build_sha
def jenkins_last_build_sha(): """ Returns the sha of the last completed jenkins build for this project. Expects JOB_URL in environment """ job_url = os.getenv('JOB_URL') job_json_url = "{0}/api/json".format(job_url) response = urllib.urlopen(job_json_url) ...
python
def jenkins_last_build_sha(): """ Returns the sha of the last completed jenkins build for this project. Expects JOB_URL in environment """ job_url = os.getenv('JOB_URL') job_json_url = "{0}/api/json".format(job_url) response = urllib.urlopen(job_json_url) ...
[ "def", "jenkins_last_build_sha", "(", ")", ":", "job_url", "=", "os", ".", "getenv", "(", "'JOB_URL'", ")", "job_json_url", "=", "\"{0}/api/json\"", ".", "format", "(", "job_url", ")", "response", "=", "urllib", ".", "urlopen", "(", "job_json_url", ")", "job...
Returns the sha of the last completed jenkins build for this project. Expects JOB_URL in environment
[ "Returns", "the", "sha", "of", "the", "last", "completed", "jenkins", "build", "for", "this", "project", ".", "Expects", "JOB_URL", "in", "environment" ]
9584a1f8a402118310b6f2a495062f388fc8dc3a
https://github.com/VJftw/invoke-tools/blob/9584a1f8a402118310b6f2a495062f388fc8dc3a/idflow/utils.py#L58-L74
train
58,614
VJftw/invoke-tools
idflow/utils.py
Utils.get_changed_files_from
def get_changed_files_from(old_commit_sha, new_commit_sha): """ Returns a list of the files changed between two commits """ return check_output( "git diff-tree --no-commit-id --name-only -r {0}..{1}".format( old_commit_sha, new_commit_sha ...
python
def get_changed_files_from(old_commit_sha, new_commit_sha): """ Returns a list of the files changed between two commits """ return check_output( "git diff-tree --no-commit-id --name-only -r {0}..{1}".format( old_commit_sha, new_commit_sha ...
[ "def", "get_changed_files_from", "(", "old_commit_sha", ",", "new_commit_sha", ")", ":", "return", "check_output", "(", "\"git diff-tree --no-commit-id --name-only -r {0}..{1}\"", ".", "format", "(", "old_commit_sha", ",", "new_commit_sha", ")", ".", "split", "(", "\" \""...
Returns a list of the files changed between two commits
[ "Returns", "a", "list", "of", "the", "files", "changed", "between", "two", "commits" ]
9584a1f8a402118310b6f2a495062f388fc8dc3a
https://github.com/VJftw/invoke-tools/blob/9584a1f8a402118310b6f2a495062f388fc8dc3a/idflow/utils.py#L77-L86
train
58,615
MKLab-ITI/reveal-user-annotation
reveal_user_annotation/mongo/store_snow_data.py
extract_snow_tweets_from_file_generator
def extract_snow_tweets_from_file_generator(json_file_path): """ A generator that opens a file containing many json tweets and yields all the tweets contained inside. Input: - json_file_path: The path of a json file containing a tweet in each line. Yields: - tweet: A tweet in python dictionary (json)...
python
def extract_snow_tweets_from_file_generator(json_file_path): """ A generator that opens a file containing many json tweets and yields all the tweets contained inside. Input: - json_file_path: The path of a json file containing a tweet in each line. Yields: - tweet: A tweet in python dictionary (json)...
[ "def", "extract_snow_tweets_from_file_generator", "(", "json_file_path", ")", ":", "with", "open", "(", "json_file_path", ",", "\"r\"", ",", "encoding", "=", "\"utf-8\"", ")", "as", "fp", ":", "for", "file_line", "in", "fp", ":", "tweet", "=", "json", ".", "...
A generator that opens a file containing many json tweets and yields all the tweets contained inside. Input: - json_file_path: The path of a json file containing a tweet in each line. Yields: - tweet: A tweet in python dictionary (json) format.
[ "A", "generator", "that", "opens", "a", "file", "containing", "many", "json", "tweets", "and", "yields", "all", "the", "tweets", "contained", "inside", "." ]
ed019c031857b091e5601f53ba3f01a499a0e3ef
https://github.com/MKLab-ITI/reveal-user-annotation/blob/ed019c031857b091e5601f53ba3f01a499a0e3ef/reveal_user_annotation/mongo/store_snow_data.py#L8-L19
train
58,616
MKLab-ITI/reveal-user-annotation
reveal_user_annotation/mongo/store_snow_data.py
extract_all_snow_tweets_from_disk_generator
def extract_all_snow_tweets_from_disk_generator(json_folder_path): """ A generator that returns all SNOW tweets stored in disk. Input: - json_file_path: The path of the folder containing the raw data. Yields: - tweet: A tweet in python dictionary (json) format. """ # Get a generator with all ...
python
def extract_all_snow_tweets_from_disk_generator(json_folder_path): """ A generator that returns all SNOW tweets stored in disk. Input: - json_file_path: The path of the folder containing the raw data. Yields: - tweet: A tweet in python dictionary (json) format. """ # Get a generator with all ...
[ "def", "extract_all_snow_tweets_from_disk_generator", "(", "json_folder_path", ")", ":", "# Get a generator with all file paths in the folder", "json_file_path_generator", "=", "(", "json_folder_path", "+", "\"/\"", "+", "name", "for", "name", "in", "os", ".", "listdir", "(...
A generator that returns all SNOW tweets stored in disk. Input: - json_file_path: The path of the folder containing the raw data. Yields: - tweet: A tweet in python dictionary (json) format.
[ "A", "generator", "that", "returns", "all", "SNOW", "tweets", "stored", "in", "disk", "." ]
ed019c031857b091e5601f53ba3f01a499a0e3ef
https://github.com/MKLab-ITI/reveal-user-annotation/blob/ed019c031857b091e5601f53ba3f01a499a0e3ef/reveal_user_annotation/mongo/store_snow_data.py#L22-L35
train
58,617
MKLab-ITI/reveal-user-annotation
reveal_user_annotation/mongo/store_snow_data.py
store_snow_tweets_from_disk_to_mongodb
def store_snow_tweets_from_disk_to_mongodb(snow_tweets_folder): """ Store all SNOW tweets in a mongodb collection. """ client = pymongo.MongoClient("localhost", 27017) db = client["snow_tweet_storage"] collection = db["tweets"] for tweet in extract_all_snow_tweets_from_disk_generator(snow_...
python
def store_snow_tweets_from_disk_to_mongodb(snow_tweets_folder): """ Store all SNOW tweets in a mongodb collection. """ client = pymongo.MongoClient("localhost", 27017) db = client["snow_tweet_storage"] collection = db["tweets"] for tweet in extract_all_snow_tweets_from_disk_generator(snow_...
[ "def", "store_snow_tweets_from_disk_to_mongodb", "(", "snow_tweets_folder", ")", ":", "client", "=", "pymongo", ".", "MongoClient", "(", "\"localhost\"", ",", "27017", ")", "db", "=", "client", "[", "\"snow_tweet_storage\"", "]", "collection", "=", "db", "[", "\"t...
Store all SNOW tweets in a mongodb collection.
[ "Store", "all", "SNOW", "tweets", "in", "a", "mongodb", "collection", "." ]
ed019c031857b091e5601f53ba3f01a499a0e3ef
https://github.com/MKLab-ITI/reveal-user-annotation/blob/ed019c031857b091e5601f53ba3f01a499a0e3ef/reveal_user_annotation/mongo/store_snow_data.py#L38-L48
train
58,618
liminspace/dju-image
dju_image/tools.py
save_file
def save_file(f, full_path): """ Saves file f to full_path and set rules. """ make_dirs_for_file_path(full_path, mode=dju_settings.DJU_IMG_CHMOD_DIR) with open(full_path, 'wb') as t: f.seek(0) while True: buf = f.read(dju_settings.DJU_IMG_RW_FILE_BUFFER_SIZE) ...
python
def save_file(f, full_path): """ Saves file f to full_path and set rules. """ make_dirs_for_file_path(full_path, mode=dju_settings.DJU_IMG_CHMOD_DIR) with open(full_path, 'wb') as t: f.seek(0) while True: buf = f.read(dju_settings.DJU_IMG_RW_FILE_BUFFER_SIZE) ...
[ "def", "save_file", "(", "f", ",", "full_path", ")", ":", "make_dirs_for_file_path", "(", "full_path", ",", "mode", "=", "dju_settings", ".", "DJU_IMG_CHMOD_DIR", ")", "with", "open", "(", "full_path", ",", "'wb'", ")", "as", "t", ":", "f", ".", "seek", ...
Saves file f to full_path and set rules.
[ "Saves", "file", "f", "to", "full_path", "and", "set", "rules", "." ]
b06eb3be2069cd6cb52cf1e26c2c761883142d4e
https://github.com/liminspace/dju-image/blob/b06eb3be2069cd6cb52cf1e26c2c761883142d4e/dju_image/tools.py#L35-L47
train
58,619
liminspace/dju-image
dju_image/tools.py
get_profile_configs
def get_profile_configs(profile=None, use_cache=True): """ Returns upload configs for profile. """ if use_cache and profile in _profile_configs_cache: return _profile_configs_cache[profile] profile_conf = None if profile is not None: try: profile_conf = dju_settings.D...
python
def get_profile_configs(profile=None, use_cache=True): """ Returns upload configs for profile. """ if use_cache and profile in _profile_configs_cache: return _profile_configs_cache[profile] profile_conf = None if profile is not None: try: profile_conf = dju_settings.D...
[ "def", "get_profile_configs", "(", "profile", "=", "None", ",", "use_cache", "=", "True", ")", ":", "if", "use_cache", "and", "profile", "in", "_profile_configs_cache", ":", "return", "_profile_configs_cache", "[", "profile", "]", "profile_conf", "=", "None", "i...
Returns upload configs for profile.
[ "Returns", "upload", "configs", "for", "profile", "." ]
b06eb3be2069cd6cb52cf1e26c2c761883142d4e
https://github.com/liminspace/dju-image/blob/b06eb3be2069cd6cb52cf1e26c2c761883142d4e/dju_image/tools.py#L50-L72
train
58,620
liminspace/dju-image
dju_image/tools.py
generate_img_id
def generate_img_id(profile, ext=None, label=None, tmp=False): """ Generates img_id. """ if ext and not ext.startswith('.'): ext = '.' + ext if label: label = re.sub(r'[^a-z0-9_\-]', '', label, flags=re.I) label = re.sub(r'_+', '_', label) label = label[:60] retur...
python
def generate_img_id(profile, ext=None, label=None, tmp=False): """ Generates img_id. """ if ext and not ext.startswith('.'): ext = '.' + ext if label: label = re.sub(r'[^a-z0-9_\-]', '', label, flags=re.I) label = re.sub(r'_+', '_', label) label = label[:60] retur...
[ "def", "generate_img_id", "(", "profile", ",", "ext", "=", "None", ",", "label", "=", "None", ",", "tmp", "=", "False", ")", ":", "if", "ext", "and", "not", "ext", ".", "startswith", "(", "'.'", ")", ":", "ext", "=", "'.'", "+", "ext", "if", "lab...
Generates img_id.
[ "Generates", "img_id", "." ]
b06eb3be2069cd6cb52cf1e26c2c761883142d4e
https://github.com/liminspace/dju-image/blob/b06eb3be2069cd6cb52cf1e26c2c761883142d4e/dju_image/tools.py#L75-L92
train
58,621
liminspace/dju-image
dju_image/tools.py
get_relative_path_from_img_id
def get_relative_path_from_img_id(img_id, variant_label=None, ext=None, create_dirs=False): """ Returns path to file relative MEDIA_URL. """ profile, base_name = img_id.split(':', 1) conf = get_profile_configs(profile) if not variant_label: status_suffix = dju_settings.DJU_IMG_UPLOAD_MAI...
python
def get_relative_path_from_img_id(img_id, variant_label=None, ext=None, create_dirs=False): """ Returns path to file relative MEDIA_URL. """ profile, base_name = img_id.split(':', 1) conf = get_profile_configs(profile) if not variant_label: status_suffix = dju_settings.DJU_IMG_UPLOAD_MAI...
[ "def", "get_relative_path_from_img_id", "(", "img_id", ",", "variant_label", "=", "None", ",", "ext", "=", "None", ",", "create_dirs", "=", "False", ")", ":", "profile", ",", "base_name", "=", "img_id", ".", "split", "(", "':'", ",", "1", ")", "conf", "=...
Returns path to file relative MEDIA_URL.
[ "Returns", "path", "to", "file", "relative", "MEDIA_URL", "." ]
b06eb3be2069cd6cb52cf1e26c2c761883142d4e
https://github.com/liminspace/dju-image/blob/b06eb3be2069cd6cb52cf1e26c2c761883142d4e/dju_image/tools.py#L101-L144
train
58,622
liminspace/dju-image
dju_image/tools.py
is_img_id_exists
def is_img_id_exists(img_id): """ Checks if img_id has real file on filesystem. """ main_rel_path = get_relative_path_from_img_id(img_id) main_path = media_path(main_rel_path) return os.path.isfile(main_path)
python
def is_img_id_exists(img_id): """ Checks if img_id has real file on filesystem. """ main_rel_path = get_relative_path_from_img_id(img_id) main_path = media_path(main_rel_path) return os.path.isfile(main_path)
[ "def", "is_img_id_exists", "(", "img_id", ")", ":", "main_rel_path", "=", "get_relative_path_from_img_id", "(", "img_id", ")", "main_path", "=", "media_path", "(", "main_rel_path", ")", "return", "os", ".", "path", ".", "isfile", "(", "main_path", ")" ]
Checks if img_id has real file on filesystem.
[ "Checks", "if", "img_id", "has", "real", "file", "on", "filesystem", "." ]
b06eb3be2069cd6cb52cf1e26c2c761883142d4e
https://github.com/liminspace/dju-image/blob/b06eb3be2069cd6cb52cf1e26c2c761883142d4e/dju_image/tools.py#L147-L153
train
58,623
liminspace/dju-image
dju_image/tools.py
is_img_id_valid
def is_img_id_valid(img_id): """ Checks if img_id is valid. """ t = re.sub(r'[^a-z0-9_:\-\.]', '', img_id, re.IGNORECASE) t = re.sub(r'\.+', '.', t) if img_id != t or img_id.count(':') != 1: return False profile, base_name = img_id.split(':', 1) if not profile or not base_name: ...
python
def is_img_id_valid(img_id): """ Checks if img_id is valid. """ t = re.sub(r'[^a-z0-9_:\-\.]', '', img_id, re.IGNORECASE) t = re.sub(r'\.+', '.', t) if img_id != t or img_id.count(':') != 1: return False profile, base_name = img_id.split(':', 1) if not profile or not base_name: ...
[ "def", "is_img_id_valid", "(", "img_id", ")", ":", "t", "=", "re", ".", "sub", "(", "r'[^a-z0-9_:\\-\\.]'", ",", "''", ",", "img_id", ",", "re", ".", "IGNORECASE", ")", "t", "=", "re", ".", "sub", "(", "r'\\.+'", ",", "'.'", ",", "t", ")", "if", ...
Checks if img_id is valid.
[ "Checks", "if", "img_id", "is", "valid", "." ]
b06eb3be2069cd6cb52cf1e26c2c761883142d4e
https://github.com/liminspace/dju-image/blob/b06eb3be2069cd6cb52cf1e26c2c761883142d4e/dju_image/tools.py#L156-L171
train
58,624
liminspace/dju-image
dju_image/tools.py
remove_all_files_of_img_id
def remove_all_files_of_img_id(img_id): """ Removes all img_id's files. """ files = get_files_by_img_id(img_id, check_hash=False) if files: os.remove(media_path(files['main'])) for fn in files['variants'].values(): os.remove(media_path(fn))
python
def remove_all_files_of_img_id(img_id): """ Removes all img_id's files. """ files = get_files_by_img_id(img_id, check_hash=False) if files: os.remove(media_path(files['main'])) for fn in files['variants'].values(): os.remove(media_path(fn))
[ "def", "remove_all_files_of_img_id", "(", "img_id", ")", ":", "files", "=", "get_files_by_img_id", "(", "img_id", ",", "check_hash", "=", "False", ")", "if", "files", ":", "os", ".", "remove", "(", "media_path", "(", "files", "[", "'main'", "]", ")", ")", ...
Removes all img_id's files.
[ "Removes", "all", "img_id", "s", "files", "." ]
b06eb3be2069cd6cb52cf1e26c2c761883142d4e
https://github.com/liminspace/dju-image/blob/b06eb3be2069cd6cb52cf1e26c2c761883142d4e/dju_image/tools.py#L236-L244
train
58,625
liminspace/dju-image
dju_image/tools.py
remove_tmp_prefix_from_filename
def remove_tmp_prefix_from_filename(filename): """ Remove tmp prefix from filename. """ if not filename.startswith(dju_settings.DJU_IMG_UPLOAD_TMP_PREFIX): raise RuntimeError(ERROR_MESSAGES['filename_hasnt_tmp_prefix'] % {'filename': filename}) return filename[len(dju_settings.DJU_IMG_UPLOAD...
python
def remove_tmp_prefix_from_filename(filename): """ Remove tmp prefix from filename. """ if not filename.startswith(dju_settings.DJU_IMG_UPLOAD_TMP_PREFIX): raise RuntimeError(ERROR_MESSAGES['filename_hasnt_tmp_prefix'] % {'filename': filename}) return filename[len(dju_settings.DJU_IMG_UPLOAD...
[ "def", "remove_tmp_prefix_from_filename", "(", "filename", ")", ":", "if", "not", "filename", ".", "startswith", "(", "dju_settings", ".", "DJU_IMG_UPLOAD_TMP_PREFIX", ")", ":", "raise", "RuntimeError", "(", "ERROR_MESSAGES", "[", "'filename_hasnt_tmp_prefix'", "]", "...
Remove tmp prefix from filename.
[ "Remove", "tmp", "prefix", "from", "filename", "." ]
b06eb3be2069cd6cb52cf1e26c2c761883142d4e
https://github.com/liminspace/dju-image/blob/b06eb3be2069cd6cb52cf1e26c2c761883142d4e/dju_image/tools.py#L251-L257
train
58,626
liminspace/dju-image
dju_image/tools.py
remove_tmp_prefix_from_file_path
def remove_tmp_prefix_from_file_path(file_path): """ Remove tmp prefix from file path or url. """ path, filename = os.path.split(file_path) return os.path.join(path, remove_tmp_prefix_from_filename(filename)).replace('\\', '/')
python
def remove_tmp_prefix_from_file_path(file_path): """ Remove tmp prefix from file path or url. """ path, filename = os.path.split(file_path) return os.path.join(path, remove_tmp_prefix_from_filename(filename)).replace('\\', '/')
[ "def", "remove_tmp_prefix_from_file_path", "(", "file_path", ")", ":", "path", ",", "filename", "=", "os", ".", "path", ".", "split", "(", "file_path", ")", "return", "os", ".", "path", ".", "join", "(", "path", ",", "remove_tmp_prefix_from_filename", "(", "...
Remove tmp prefix from file path or url.
[ "Remove", "tmp", "prefix", "from", "file", "path", "or", "url", "." ]
b06eb3be2069cd6cb52cf1e26c2c761883142d4e
https://github.com/liminspace/dju-image/blob/b06eb3be2069cd6cb52cf1e26c2c761883142d4e/dju_image/tools.py#L260-L265
train
58,627
liminspace/dju-image
dju_image/tools.py
make_permalink
def make_permalink(img_id): """ Removes tmp prefix from filename and rename main and variant files. Returns img_id without tmp prefix. """ profile, filename = img_id.split(':', 1) new_img_id = profile + ':' + remove_tmp_prefix_from_filename(filename) urls = get_files_by_img_id(img_id) if...
python
def make_permalink(img_id): """ Removes tmp prefix from filename and rename main and variant files. Returns img_id without tmp prefix. """ profile, filename = img_id.split(':', 1) new_img_id = profile + ':' + remove_tmp_prefix_from_filename(filename) urls = get_files_by_img_id(img_id) if...
[ "def", "make_permalink", "(", "img_id", ")", ":", "profile", ",", "filename", "=", "img_id", ".", "split", "(", "':'", ",", "1", ")", "new_img_id", "=", "profile", "+", "':'", "+", "remove_tmp_prefix_from_filename", "(", "filename", ")", "urls", "=", "get_...
Removes tmp prefix from filename and rename main and variant files. Returns img_id without tmp prefix.
[ "Removes", "tmp", "prefix", "from", "filename", "and", "rename", "main", "and", "variant", "files", ".", "Returns", "img_id", "without", "tmp", "prefix", "." ]
b06eb3be2069cd6cb52cf1e26c2c761883142d4e
https://github.com/liminspace/dju-image/blob/b06eb3be2069cd6cb52cf1e26c2c761883142d4e/dju_image/tools.py#L268-L283
train
58,628
liminspace/dju-image
dju_image/tools.py
upload_from_fs
def upload_from_fs(fn, profile=None, label=None): """ Saves image from fn with TMP prefix and returns img_id. """ if not os.path.isfile(fn): raise ValueError('File is not exists: {}'.format(fn)) if profile is None: profile = 'default' conf = get_profile_configs(profile) with ...
python
def upload_from_fs(fn, profile=None, label=None): """ Saves image from fn with TMP prefix and returns img_id. """ if not os.path.isfile(fn): raise ValueError('File is not exists: {}'.format(fn)) if profile is None: profile = 'default' conf = get_profile_configs(profile) with ...
[ "def", "upload_from_fs", "(", "fn", ",", "profile", "=", "None", ",", "label", "=", "None", ")", ":", "if", "not", "os", ".", "path", ".", "isfile", "(", "fn", ")", ":", "raise", "ValueError", "(", "'File is not exists: {}'", ".", "format", "(", "fn", ...
Saves image from fn with TMP prefix and returns img_id.
[ "Saves", "image", "from", "fn", "with", "TMP", "prefix", "and", "returns", "img_id", "." ]
b06eb3be2069cd6cb52cf1e26c2c761883142d4e
https://github.com/liminspace/dju-image/blob/b06eb3be2069cd6cb52cf1e26c2c761883142d4e/dju_image/tools.py#L308-L323
train
58,629
liminspace/dju-image
dju_image/tools.py
upload_from_fileobject
def upload_from_fileobject(f, profile=None, label=None): """ Saves image from f with TMP prefix and returns img_id. """ if profile is None: profile = 'default' conf = get_profile_configs(profile) f.seek(0) if not is_image(f, types=conf['TYPES']): msg = (('Format of uploaded f...
python
def upload_from_fileobject(f, profile=None, label=None): """ Saves image from f with TMP prefix and returns img_id. """ if profile is None: profile = 'default' conf = get_profile_configs(profile) f.seek(0) if not is_image(f, types=conf['TYPES']): msg = (('Format of uploaded f...
[ "def", "upload_from_fileobject", "(", "f", ",", "profile", "=", "None", ",", "label", "=", "None", ")", ":", "if", "profile", "is", "None", ":", "profile", "=", "'default'", "conf", "=", "get_profile_configs", "(", "profile", ")", "f", ".", "seek", "(", ...
Saves image from f with TMP prefix and returns img_id.
[ "Saves", "image", "from", "f", "with", "TMP", "prefix", "and", "returns", "img_id", "." ]
b06eb3be2069cd6cb52cf1e26c2c761883142d4e
https://github.com/liminspace/dju-image/blob/b06eb3be2069cd6cb52cf1e26c2c761883142d4e/dju_image/tools.py#L326-L339
train
58,630
PonteIneptique/flask-github-proxy
flask_github_proxy/__init__.py
GithubProxy.request
def request(self, method, url, **kwargs): """ Unified method to make request to the Github API :param method: HTTP Method to use :param url: URL to reach :param kwargs: dictionary of arguments (params for URL parameters, data for post/put data) :return: Response """ ...
python
def request(self, method, url, **kwargs): """ Unified method to make request to the Github API :param method: HTTP Method to use :param url: URL to reach :param kwargs: dictionary of arguments (params for URL parameters, data for post/put data) :return: Response """ ...
[ "def", "request", "(", "self", ",", "method", ",", "url", ",", "*", "*", "kwargs", ")", ":", "if", "\"data\"", "in", "kwargs", ":", "kwargs", "[", "\"data\"", "]", "=", "json", ".", "dumps", "(", "kwargs", "[", "\"data\"", "]", ")", "kwargs", "[", ...
Unified method to make request to the Github API :param method: HTTP Method to use :param url: URL to reach :param kwargs: dictionary of arguments (params for URL parameters, data for post/put data) :return: Response
[ "Unified", "method", "to", "make", "request", "to", "the", "Github", "API" ]
f0a60639342f7c0834360dc12a099bfc3a06d939
https://github.com/PonteIneptique/flask-github-proxy/blob/f0a60639342f7c0834360dc12a099bfc3a06d939/flask_github_proxy/__init__.py#L113-L141
train
58,631
PonteIneptique/flask-github-proxy
flask_github_proxy/__init__.py
GithubProxy.default_branch
def default_branch(self, file): """ Decide the name of the default branch given the file and the configuration :param file: File with informations about it :return: Branch Name """ if isinstance(self.__default_branch__, str): return self.__default_branch__ el...
python
def default_branch(self, file): """ Decide the name of the default branch given the file and the configuration :param file: File with informations about it :return: Branch Name """ if isinstance(self.__default_branch__, str): return self.__default_branch__ el...
[ "def", "default_branch", "(", "self", ",", "file", ")", ":", "if", "isinstance", "(", "self", ".", "__default_branch__", ",", "str", ")", ":", "return", "self", ".", "__default_branch__", "elif", "self", ".", "__default_branch__", "==", "GithubProxy", ".", "...
Decide the name of the default branch given the file and the configuration :param file: File with informations about it :return: Branch Name
[ "Decide", "the", "name", "of", "the", "default", "branch", "given", "the", "file", "and", "the", "configuration" ]
f0a60639342f7c0834360dc12a099bfc3a06d939
https://github.com/PonteIneptique/flask-github-proxy/blob/f0a60639342f7c0834360dc12a099bfc3a06d939/flask_github_proxy/__init__.py#L143-L154
train
58,632
PonteIneptique/flask-github-proxy
flask_github_proxy/__init__.py
GithubProxy.init_app
def init_app(self, app): """ Initialize the application and register the blueprint :param app: Flask Application :return: Blueprint of the current nemo app :rtype: flask.Blueprint """ self.app = app self.__blueprint__ = Blueprint( self.__name__, ...
python
def init_app(self, app): """ Initialize the application and register the blueprint :param app: Flask Application :return: Blueprint of the current nemo app :rtype: flask.Blueprint """ self.app = app self.__blueprint__ = Blueprint( self.__name__, ...
[ "def", "init_app", "(", "self", ",", "app", ")", ":", "self", ".", "app", "=", "app", "self", ".", "__blueprint__", "=", "Blueprint", "(", "self", ".", "__name__", ",", "self", ".", "__name__", ",", "url_prefix", "=", "self", ".", "__prefix__", ",", ...
Initialize the application and register the blueprint :param app: Flask Application :return: Blueprint of the current nemo app :rtype: flask.Blueprint
[ "Initialize", "the", "application", "and", "register", "the", "blueprint" ]
f0a60639342f7c0834360dc12a099bfc3a06d939
https://github.com/PonteIneptique/flask-github-proxy/blob/f0a60639342f7c0834360dc12a099bfc3a06d939/flask_github_proxy/__init__.py#L184-L208
train
58,633
PonteIneptique/flask-github-proxy
flask_github_proxy/__init__.py
GithubProxy.put
def put(self, file): """ Create a new file on github :param file: File to create :return: File or self.ProxyError """ input_ = { "message": file.logs, "author": file.author.dict(), "content": file.base64, "branch": file.branch ...
python
def put(self, file): """ Create a new file on github :param file: File to create :return: File or self.ProxyError """ input_ = { "message": file.logs, "author": file.author.dict(), "content": file.base64, "branch": file.branch ...
[ "def", "put", "(", "self", ",", "file", ")", ":", "input_", "=", "{", "\"message\"", ":", "file", ".", "logs", ",", "\"author\"", ":", "file", ".", "author", ".", "dict", "(", ")", ",", "\"content\"", ":", "file", ".", "base64", ",", "\"branch\"", ...
Create a new file on github :param file: File to create :return: File or self.ProxyError
[ "Create", "a", "new", "file", "on", "github" ]
f0a60639342f7c0834360dc12a099bfc3a06d939
https://github.com/PonteIneptique/flask-github-proxy/blob/f0a60639342f7c0834360dc12a099bfc3a06d939/flask_github_proxy/__init__.py#L210-L240
train
58,634
PonteIneptique/flask-github-proxy
flask_github_proxy/__init__.py
GithubProxy.get
def get(self, file): """ Check on github if a file exists :param file: File to check status of :return: File with new information, including blob, or Error :rtype: File or self.ProxyError """ uri = "{api}/repos/{origin}/contents/{path}".format( api=self.githu...
python
def get(self, file): """ Check on github if a file exists :param file: File to check status of :return: File with new information, including blob, or Error :rtype: File or self.ProxyError """ uri = "{api}/repos/{origin}/contents/{path}".format( api=self.githu...
[ "def", "get", "(", "self", ",", "file", ")", ":", "uri", "=", "\"{api}/repos/{origin}/contents/{path}\"", ".", "format", "(", "api", "=", "self", ".", "github_api_url", ",", "origin", "=", "self", ".", "origin", ",", "path", "=", "file", ".", "path", ")"...
Check on github if a file exists :param file: File to check status of :return: File with new information, including blob, or Error :rtype: File or self.ProxyError
[ "Check", "on", "github", "if", "a", "file", "exists" ]
f0a60639342f7c0834360dc12a099bfc3a06d939
https://github.com/PonteIneptique/flask-github-proxy/blob/f0a60639342f7c0834360dc12a099bfc3a06d939/flask_github_proxy/__init__.py#L242-L273
train
58,635
PonteIneptique/flask-github-proxy
flask_github_proxy/__init__.py
GithubProxy.update
def update(self, file): """ Make an update query on Github API for given file :param file: File to update, with its content :return: File with new information, including success (or Error) """ params = { "message": file.logs, "author": file.author.dict(),...
python
def update(self, file): """ Make an update query on Github API for given file :param file: File to update, with its content :return: File with new information, including success (or Error) """ params = { "message": file.logs, "author": file.author.dict(),...
[ "def", "update", "(", "self", ",", "file", ")", ":", "params", "=", "{", "\"message\"", ":", "file", ".", "logs", ",", "\"author\"", ":", "file", ".", "author", ".", "dict", "(", ")", ",", "\"content\"", ":", "file", ".", "base64", ",", "\"sha\"", ...
Make an update query on Github API for given file :param file: File to update, with its content :return: File with new information, including success (or Error)
[ "Make", "an", "update", "query", "on", "Github", "API", "for", "given", "file" ]
f0a60639342f7c0834360dc12a099bfc3a06d939
https://github.com/PonteIneptique/flask-github-proxy/blob/f0a60639342f7c0834360dc12a099bfc3a06d939/flask_github_proxy/__init__.py#L275-L305
train
58,636
PonteIneptique/flask-github-proxy
flask_github_proxy/__init__.py
GithubProxy.pull_request
def pull_request(self, file): """ Create a pull request :param file: File to push through pull request :return: URL of the PullRequest or Proxy Error """ uri = "{api}/repos/{upstream}/pulls".format( api=self.github_api_url, upstream=self.upstream, ...
python
def pull_request(self, file): """ Create a pull request :param file: File to push through pull request :return: URL of the PullRequest or Proxy Error """ uri = "{api}/repos/{upstream}/pulls".format( api=self.github_api_url, upstream=self.upstream, ...
[ "def", "pull_request", "(", "self", ",", "file", ")", ":", "uri", "=", "\"{api}/repos/{upstream}/pulls\"", ".", "format", "(", "api", "=", "self", ".", "github_api_url", ",", "upstream", "=", "self", ".", "upstream", ",", "path", "=", "file", ".", "path", ...
Create a pull request :param file: File to push through pull request :return: URL of the PullRequest or Proxy Error
[ "Create", "a", "pull", "request" ]
f0a60639342f7c0834360dc12a099bfc3a06d939
https://github.com/PonteIneptique/flask-github-proxy/blob/f0a60639342f7c0834360dc12a099bfc3a06d939/flask_github_proxy/__init__.py#L307-L336
train
58,637
PonteIneptique/flask-github-proxy
flask_github_proxy/__init__.py
GithubProxy.get_ref
def get_ref(self, branch, origin=None): """ Check if a reference exists :param branch: The branch to check if it exists :return: Sha of the branch if it exists, False if it does not exist, self.ProxyError if it went wrong """ if not origin: origin = self.origin ...
python
def get_ref(self, branch, origin=None): """ Check if a reference exists :param branch: The branch to check if it exists :return: Sha of the branch if it exists, False if it does not exist, self.ProxyError if it went wrong """ if not origin: origin = self.origin ...
[ "def", "get_ref", "(", "self", ",", "branch", ",", "origin", "=", "None", ")", ":", "if", "not", "origin", ":", "origin", "=", "self", ".", "origin", "uri", "=", "\"{api}/repos/{origin}/git/refs/heads/{branch}\"", ".", "format", "(", "api", "=", "self", "....
Check if a reference exists :param branch: The branch to check if it exists :return: Sha of the branch if it exists, False if it does not exist, self.ProxyError if it went wrong
[ "Check", "if", "a", "reference", "exists" ]
f0a60639342f7c0834360dc12a099bfc3a06d939
https://github.com/PonteIneptique/flask-github-proxy/blob/f0a60639342f7c0834360dc12a099bfc3a06d939/flask_github_proxy/__init__.py#L338-L368
train
58,638
PonteIneptique/flask-github-proxy
flask_github_proxy/__init__.py
GithubProxy.make_ref
def make_ref(self, branch): """ Make a branch on github :param branch: Name of the branch to create :return: Sha of the branch or self.ProxyError """ master_sha = self.get_ref(self.master_upstream) if not isinstance(master_sha, str): return self.ProxyError( ...
python
def make_ref(self, branch): """ Make a branch on github :param branch: Name of the branch to create :return: Sha of the branch or self.ProxyError """ master_sha = self.get_ref(self.master_upstream) if not isinstance(master_sha, str): return self.ProxyError( ...
[ "def", "make_ref", "(", "self", ",", "branch", ")", ":", "master_sha", "=", "self", ".", "get_ref", "(", "self", ".", "master_upstream", ")", "if", "not", "isinstance", "(", "master_sha", ",", "str", ")", ":", "return", "self", ".", "ProxyError", "(", ...
Make a branch on github :param branch: Name of the branch to create :return: Sha of the branch or self.ProxyError
[ "Make", "a", "branch", "on", "github" ]
f0a60639342f7c0834360dc12a099bfc3a06d939
https://github.com/PonteIneptique/flask-github-proxy/blob/f0a60639342f7c0834360dc12a099bfc3a06d939/flask_github_proxy/__init__.py#L370-L405
train
58,639
PonteIneptique/flask-github-proxy
flask_github_proxy/__init__.py
GithubProxy.check_sha
def check_sha(self, sha, content): """ Check sent sha against the salted hash of the content :param sha: SHA sent through fproxy-secure-hash header :param content: Base 64 encoded Content :return: Boolean indicating equality """ rightful_sha = sha256(bytes("{}{}".format(...
python
def check_sha(self, sha, content): """ Check sent sha against the salted hash of the content :param sha: SHA sent through fproxy-secure-hash header :param content: Base 64 encoded Content :return: Boolean indicating equality """ rightful_sha = sha256(bytes("{}{}".format(...
[ "def", "check_sha", "(", "self", ",", "sha", ",", "content", ")", ":", "rightful_sha", "=", "sha256", "(", "bytes", "(", "\"{}{}\"", ".", "format", "(", "content", ",", "self", ".", "secret", ")", ",", "\"utf-8\"", ")", ")", ".", "hexdigest", "(", ")...
Check sent sha against the salted hash of the content :param sha: SHA sent through fproxy-secure-hash header :param content: Base 64 encoded Content :return: Boolean indicating equality
[ "Check", "sent", "sha", "against", "the", "salted", "hash", "of", "the", "content" ]
f0a60639342f7c0834360dc12a099bfc3a06d939
https://github.com/PonteIneptique/flask-github-proxy/blob/f0a60639342f7c0834360dc12a099bfc3a06d939/flask_github_proxy/__init__.py#L407-L415
train
58,640
PonteIneptique/flask-github-proxy
flask_github_proxy/__init__.py
GithubProxy.patch_ref
def patch_ref(self, sha): """ Patch reference on the origin master branch :param sha: Sha to use for the branch :return: Status of success :rtype: str or self.ProxyError """ uri = "{api}/repos/{origin}/git/refs/heads/{branch}".format( api=self.github_api_url,...
python
def patch_ref(self, sha): """ Patch reference on the origin master branch :param sha: Sha to use for the branch :return: Status of success :rtype: str or self.ProxyError """ uri = "{api}/repos/{origin}/git/refs/heads/{branch}".format( api=self.github_api_url,...
[ "def", "patch_ref", "(", "self", ",", "sha", ")", ":", "uri", "=", "\"{api}/repos/{origin}/git/refs/heads/{branch}\"", ".", "format", "(", "api", "=", "self", ".", "github_api_url", ",", "origin", "=", "self", ".", "origin", ",", "branch", "=", "self", ".", ...
Patch reference on the origin master branch :param sha: Sha to use for the branch :return: Status of success :rtype: str or self.ProxyError
[ "Patch", "reference", "on", "the", "origin", "master", "branch" ]
f0a60639342f7c0834360dc12a099bfc3a06d939
https://github.com/PonteIneptique/flask-github-proxy/blob/f0a60639342f7c0834360dc12a099bfc3a06d939/flask_github_proxy/__init__.py#L417-L451
train
58,641
PonteIneptique/flask-github-proxy
flask_github_proxy/__init__.py
GithubProxy.r_receive
def r_receive(self, filename): """ Function which receives the data from Perseids - Check the branch does not exist - Make the branch if needed - Receive PUT from Perseids - Check if content exist - Update/Create content - Open Pull Reques...
python
def r_receive(self, filename): """ Function which receives the data from Perseids - Check the branch does not exist - Make the branch if needed - Receive PUT from Perseids - Check if content exist - Update/Create content - Open Pull Reques...
[ "def", "r_receive", "(", "self", ",", "filename", ")", ":", "###########################################", "# Retrieving data", "###########################################", "content", "=", "request", ".", "data", ".", "decode", "(", "\"utf-8\"", ")", "# Content checking",...
Function which receives the data from Perseids - Check the branch does not exist - Make the branch if needed - Receive PUT from Perseids - Check if content exist - Update/Create content - Open Pull Request - Return PR link to Perseids ...
[ "Function", "which", "receives", "the", "data", "from", "Perseids" ]
f0a60639342f7c0834360dc12a099bfc3a06d939
https://github.com/PonteIneptique/flask-github-proxy/blob/f0a60639342f7c0834360dc12a099bfc3a06d939/flask_github_proxy/__init__.py#L453-L557
train
58,642
PonteIneptique/flask-github-proxy
flask_github_proxy/__init__.py
GithubProxy.r_update
def r_update(self): """ Updates a fork Master - Check the ref of the origin repository - Patch reference of fork repository - Return status to Perseids :return: JSON Response with status_code 201 if successful. """ # Getting Master Branch up...
python
def r_update(self): """ Updates a fork Master - Check the ref of the origin repository - Patch reference of fork repository - Return status to Perseids :return: JSON Response with status_code 201 if successful. """ # Getting Master Branch up...
[ "def", "r_update", "(", "self", ")", ":", "# Getting Master Branch", "upstream", "=", "self", ".", "get_ref", "(", "self", ".", "master_upstream", ",", "origin", "=", "self", ".", "upstream", ")", "if", "isinstance", "(", "upstream", ",", "bool", ")", ":",...
Updates a fork Master - Check the ref of the origin repository - Patch reference of fork repository - Return status to Perseids :return: JSON Response with status_code 201 if successful.
[ "Updates", "a", "fork", "Master" ]
f0a60639342f7c0834360dc12a099bfc3a06d939
https://github.com/PonteIneptique/flask-github-proxy/blob/f0a60639342f7c0834360dc12a099bfc3a06d939/flask_github_proxy/__init__.py#L559-L588
train
58,643
AtomHash/evernode
evernode/models/password_reset_model.py
PasswordResetModel.delete_where_user_id
def delete_where_user_id(cls, user_id): """ delete by email """ result = cls.where_user_id(user_id) if result is None: return None result.delete() return True
python
def delete_where_user_id(cls, user_id): """ delete by email """ result = cls.where_user_id(user_id) if result is None: return None result.delete() return True
[ "def", "delete_where_user_id", "(", "cls", ",", "user_id", ")", ":", "result", "=", "cls", ".", "where_user_id", "(", "user_id", ")", "if", "result", "is", "None", ":", "return", "None", "result", ".", "delete", "(", ")", "return", "True" ]
delete by email
[ "delete", "by", "email" ]
b2fb91555fb937a3f3eba41db56dee26f9b034be
https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/models/password_reset_model.py#L32-L38
train
58,644
MacHu-GWU/crawl_zillow-project
crawl_zillow/helpers.py
int_filter
def int_filter(text): """Extract integer from text. **中文文档** 摘除文本内的整数。 """ res = list() for char in text: if char.isdigit(): res.append(char) return int("".join(res))
python
def int_filter(text): """Extract integer from text. **中文文档** 摘除文本内的整数。 """ res = list() for char in text: if char.isdigit(): res.append(char) return int("".join(res))
[ "def", "int_filter", "(", "text", ")", ":", "res", "=", "list", "(", ")", "for", "char", "in", "text", ":", "if", "char", ".", "isdigit", "(", ")", ":", "res", ".", "append", "(", "char", ")", "return", "int", "(", "\"\"", ".", "join", "(", "re...
Extract integer from text. **中文文档** 摘除文本内的整数。
[ "Extract", "integer", "from", "text", "." ]
c6d7ca8e4c80e7e7e963496433ef73df1413c16e
https://github.com/MacHu-GWU/crawl_zillow-project/blob/c6d7ca8e4c80e7e7e963496433ef73df1413c16e/crawl_zillow/helpers.py#L5-L16
train
58,645
MacHu-GWU/crawl_zillow-project
crawl_zillow/helpers.py
float_filter
def float_filter(text): """Extract float from text. **中文文档** 摘除文本内的小数。 """ res = list() for char in text: if (char.isdigit() or (char == ".")): res.append(char) return float("".join(res))
python
def float_filter(text): """Extract float from text. **中文文档** 摘除文本内的小数。 """ res = list() for char in text: if (char.isdigit() or (char == ".")): res.append(char) return float("".join(res))
[ "def", "float_filter", "(", "text", ")", ":", "res", "=", "list", "(", ")", "for", "char", "in", "text", ":", "if", "(", "char", ".", "isdigit", "(", ")", "or", "(", "char", "==", "\".\"", ")", ")", ":", "res", ".", "append", "(", "char", ")", ...
Extract float from text. **中文文档** 摘除文本内的小数。
[ "Extract", "float", "from", "text", "." ]
c6d7ca8e4c80e7e7e963496433ef73df1413c16e
https://github.com/MacHu-GWU/crawl_zillow-project/blob/c6d7ca8e4c80e7e7e963496433ef73df1413c16e/crawl_zillow/helpers.py#L19-L30
train
58,646
dariusbakunas/rawdisk
rawdisk/plugins/filesystems/apple_boot/apple_boot_volume.py
AppleBootVolume.load
def load(self, filename, offset): """Will eventually load information for Apple_Boot volume. Not yet implemented""" try: self.offset = offset # self.fd = open(filename, 'rb') # self.fd.close() except IOError as e: print(e)
python
def load(self, filename, offset): """Will eventually load information for Apple_Boot volume. Not yet implemented""" try: self.offset = offset # self.fd = open(filename, 'rb') # self.fd.close() except IOError as e: print(e)
[ "def", "load", "(", "self", ",", "filename", ",", "offset", ")", ":", "try", ":", "self", ".", "offset", "=", "offset", "# self.fd = open(filename, 'rb')", "# self.fd.close()", "except", "IOError", "as", "e", ":", "print", "(", "e", ")" ]
Will eventually load information for Apple_Boot volume. Not yet implemented
[ "Will", "eventually", "load", "information", "for", "Apple_Boot", "volume", ".", "Not", "yet", "implemented" ]
1dc9d0b377fe5da3c406ccec4abc238c54167403
https://github.com/dariusbakunas/rawdisk/blob/1dc9d0b377fe5da3c406ccec4abc238c54167403/rawdisk/plugins/filesystems/apple_boot/apple_boot_volume.py#L13-L21
train
58,647
zibertscrem/hexdi
hexdi/__init__.py
resolve
def resolve(accessor: hexdi.core.clstype) -> __gentype__.T: """ shortcut for resolving from root container :param accessor: accessor for resolving object :return: resolved object of requested type """ return hexdi.core.get_root_container().resolve(accessor=accessor)
python
def resolve(accessor: hexdi.core.clstype) -> __gentype__.T: """ shortcut for resolving from root container :param accessor: accessor for resolving object :return: resolved object of requested type """ return hexdi.core.get_root_container().resolve(accessor=accessor)
[ "def", "resolve", "(", "accessor", ":", "hexdi", ".", "core", ".", "clstype", ")", "->", "__gentype__", ".", "T", ":", "return", "hexdi", ".", "core", ".", "get_root_container", "(", ")", ".", "resolve", "(", "accessor", "=", "accessor", ")" ]
shortcut for resolving from root container :param accessor: accessor for resolving object :return: resolved object of requested type
[ "shortcut", "for", "resolving", "from", "root", "container" ]
4875598299c53f984f2bb1b37060fd42bb7aba84
https://github.com/zibertscrem/hexdi/blob/4875598299c53f984f2bb1b37060fd42bb7aba84/hexdi/__init__.py#L39-L46
train
58,648
zibertscrem/hexdi
hexdi/__init__.py
bind_type
def bind_type(type_to_bind: hexdi.core.restype, accessor: hexdi.core.clstype, lifetime_manager: hexdi.core.ltype): """ shortcut for bind_type on root container :param type_to_bind: type that will be resolved by accessor :param accessor: accessor for resolving object :param lifetime_manager: type of...
python
def bind_type(type_to_bind: hexdi.core.restype, accessor: hexdi.core.clstype, lifetime_manager: hexdi.core.ltype): """ shortcut for bind_type on root container :param type_to_bind: type that will be resolved by accessor :param accessor: accessor for resolving object :param lifetime_manager: type of...
[ "def", "bind_type", "(", "type_to_bind", ":", "hexdi", ".", "core", ".", "restype", ",", "accessor", ":", "hexdi", ".", "core", ".", "clstype", ",", "lifetime_manager", ":", "hexdi", ".", "core", ".", "ltype", ")", ":", "hexdi", ".", "core", ".", "get_...
shortcut for bind_type on root container :param type_to_bind: type that will be resolved by accessor :param accessor: accessor for resolving object :param lifetime_manager: type of lifetime manager for this binding
[ "shortcut", "for", "bind_type", "on", "root", "container" ]
4875598299c53f984f2bb1b37060fd42bb7aba84
https://github.com/zibertscrem/hexdi/blob/4875598299c53f984f2bb1b37060fd42bb7aba84/hexdi/__init__.py#L68-L76
train
58,649
zibertscrem/hexdi
hexdi/__init__.py
bind_permanent
def bind_permanent(type_to_bind: hexdi.core.restype, accessor: hexdi.core.clstype): """ shortcut for bind_type with PermanentLifeTimeManager on root container :param type_to_bind: type that will be resolved by accessor :param accessor: accessor for resolving object """ hexdi.core.get_root_conta...
python
def bind_permanent(type_to_bind: hexdi.core.restype, accessor: hexdi.core.clstype): """ shortcut for bind_type with PermanentLifeTimeManager on root container :param type_to_bind: type that will be resolved by accessor :param accessor: accessor for resolving object """ hexdi.core.get_root_conta...
[ "def", "bind_permanent", "(", "type_to_bind", ":", "hexdi", ".", "core", ".", "restype", ",", "accessor", ":", "hexdi", ".", "core", ".", "clstype", ")", ":", "hexdi", ".", "core", ".", "get_root_container", "(", ")", ".", "bind_type", "(", "type_to_bind",...
shortcut for bind_type with PermanentLifeTimeManager on root container :param type_to_bind: type that will be resolved by accessor :param accessor: accessor for resolving object
[ "shortcut", "for", "bind_type", "with", "PermanentLifeTimeManager", "on", "root", "container" ]
4875598299c53f984f2bb1b37060fd42bb7aba84
https://github.com/zibertscrem/hexdi/blob/4875598299c53f984f2bb1b37060fd42bb7aba84/hexdi/__init__.py#L79-L86
train
58,650
zibertscrem/hexdi
hexdi/__init__.py
bind_transient
def bind_transient(type_to_bind: hexdi.core.restype, accessor: hexdi.core.clstype): """ shortcut for bind_type with PerResolveLifeTimeManager on root container :param type_to_bind: type that will be resolved by accessor :param accessor: accessor for resolving object """ hexdi.core.get_root_cont...
python
def bind_transient(type_to_bind: hexdi.core.restype, accessor: hexdi.core.clstype): """ shortcut for bind_type with PerResolveLifeTimeManager on root container :param type_to_bind: type that will be resolved by accessor :param accessor: accessor for resolving object """ hexdi.core.get_root_cont...
[ "def", "bind_transient", "(", "type_to_bind", ":", "hexdi", ".", "core", ".", "restype", ",", "accessor", ":", "hexdi", ".", "core", ".", "clstype", ")", ":", "hexdi", ".", "core", ".", "get_root_container", "(", ")", ".", "bind_type", "(", "type_to_bind",...
shortcut for bind_type with PerResolveLifeTimeManager on root container :param type_to_bind: type that will be resolved by accessor :param accessor: accessor for resolving object
[ "shortcut", "for", "bind_type", "with", "PerResolveLifeTimeManager", "on", "root", "container" ]
4875598299c53f984f2bb1b37060fd42bb7aba84
https://github.com/zibertscrem/hexdi/blob/4875598299c53f984f2bb1b37060fd42bb7aba84/hexdi/__init__.py#L89-L96
train
58,651
The-Politico/politico-civic-demography
demography/management/commands/bootstrap/fetch/_series.py
GetSeries.get_series
def get_series(self, series): """ Returns a census series API handler. """ if series == "acs1": return self.census.acs1dp elif series == "acs5": return self.census.acs5 elif series == "sf1": return self.census.sf1 elif series ==...
python
def get_series(self, series): """ Returns a census series API handler. """ if series == "acs1": return self.census.acs1dp elif series == "acs5": return self.census.acs5 elif series == "sf1": return self.census.sf1 elif series ==...
[ "def", "get_series", "(", "self", ",", "series", ")", ":", "if", "series", "==", "\"acs1\"", ":", "return", "self", ".", "census", ".", "acs1dp", "elif", "series", "==", "\"acs5\"", ":", "return", "self", ".", "census", ".", "acs5", "elif", "series", "...
Returns a census series API handler.
[ "Returns", "a", "census", "series", "API", "handler", "." ]
080bb964b64b06db7fd04386530e893ceed1cf98
https://github.com/The-Politico/politico-civic-demography/blob/080bb964b64b06db7fd04386530e893ceed1cf98/demography/management/commands/bootstrap/fetch/_series.py#L2-L15
train
58,652
helixyte/everest
everest/repositories/manager.py
RepositoryManager.setup_system_repository
def setup_system_repository(self, repository_type, reset_on_start, repository_class=None): """ Sets up the system repository with the given repository type. :param str repository_type: Repository type to use for the SYSTEM repository. :param boo...
python
def setup_system_repository(self, repository_type, reset_on_start, repository_class=None): """ Sets up the system repository with the given repository type. :param str repository_type: Repository type to use for the SYSTEM repository. :param boo...
[ "def", "setup_system_repository", "(", "self", ",", "repository_type", ",", "reset_on_start", ",", "repository_class", "=", "None", ")", ":", "# Set up the system entity repository (this does not join the", "# transaction and is in autocommit mode).", "cnf", "=", "dict", "(", ...
Sets up the system repository with the given repository type. :param str repository_type: Repository type to use for the SYSTEM repository. :param bool reset_on_start: Flag to indicate whether stored system resources should be discarded on startup. :param repository_class: c...
[ "Sets", "up", "the", "system", "repository", "with", "the", "given", "repository", "type", "." ]
70c9b93c3061db5cb62428349d18b8fb8566411b
https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/repositories/manager.py#L91-L111
train
58,653
helixyte/everest
everest/repositories/manager.py
RepositoryManager.initialize_all
def initialize_all(self): """ Convenience method to initialize all repositories that have not been initialized yet. """ for repo in itervalues_(self.__repositories): if not repo.is_initialized: repo.initialize()
python
def initialize_all(self): """ Convenience method to initialize all repositories that have not been initialized yet. """ for repo in itervalues_(self.__repositories): if not repo.is_initialized: repo.initialize()
[ "def", "initialize_all", "(", "self", ")", ":", "for", "repo", "in", "itervalues_", "(", "self", ".", "__repositories", ")", ":", "if", "not", "repo", ".", "is_initialized", ":", "repo", ".", "initialize", "(", ")" ]
Convenience method to initialize all repositories that have not been initialized yet.
[ "Convenience", "method", "to", "initialize", "all", "repositories", "that", "have", "not", "been", "initialized", "yet", "." ]
70c9b93c3061db5cb62428349d18b8fb8566411b
https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/repositories/manager.py#L113-L120
train
58,654
silver-castle/mach9
mach9/response.py
file
async def file(location, mime_type=None, headers=None, _range=None): '''Return a response object with file data. :param location: Location of file on system. :param mime_type: Specific mime_type. :param headers: Custom Headers. :param _range: ''' filename = path.split(location)[-1] asy...
python
async def file(location, mime_type=None, headers=None, _range=None): '''Return a response object with file data. :param location: Location of file on system. :param mime_type: Specific mime_type. :param headers: Custom Headers. :param _range: ''' filename = path.split(location)[-1] asy...
[ "async", "def", "file", "(", "location", ",", "mime_type", "=", "None", ",", "headers", "=", "None", ",", "_range", "=", "None", ")", ":", "filename", "=", "path", ".", "split", "(", "location", ")", "[", "-", "1", "]", "async", "with", "open_async",...
Return a response object with file data. :param location: Location of file on system. :param mime_type: Specific mime_type. :param headers: Custom Headers. :param _range:
[ "Return", "a", "response", "object", "with", "file", "data", "." ]
7a623aab3c70d89d36ade6901b6307e115400c5e
https://github.com/silver-castle/mach9/blob/7a623aab3c70d89d36ade6901b6307e115400c5e/mach9/response.py#L349-L373
train
58,655
sdcooke/django_bundles
django_bundles/core.py
get_bundles
def get_bundles(): """ Used to cache the bundle definitions rather than loading from config every time they're used """ global _cached_bundles if not _cached_bundles: _cached_bundles = BundleManager() for bundle_conf in bundles_settings.BUNDLES: _cached_bundles[bundle_c...
python
def get_bundles(): """ Used to cache the bundle definitions rather than loading from config every time they're used """ global _cached_bundles if not _cached_bundles: _cached_bundles = BundleManager() for bundle_conf in bundles_settings.BUNDLES: _cached_bundles[bundle_c...
[ "def", "get_bundles", "(", ")", ":", "global", "_cached_bundles", "if", "not", "_cached_bundles", ":", "_cached_bundles", "=", "BundleManager", "(", ")", "for", "bundle_conf", "in", "bundles_settings", ".", "BUNDLES", ":", "_cached_bundles", "[", "bundle_conf", "[...
Used to cache the bundle definitions rather than loading from config every time they're used
[ "Used", "to", "cache", "the", "bundle", "definitions", "rather", "than", "loading", "from", "config", "every", "time", "they", "re", "used" ]
2810fc455ec7391283792c1f108f4e8340f5d12f
https://github.com/sdcooke/django_bundles/blob/2810fc455ec7391283792c1f108f4e8340f5d12f/django_bundles/core.py#L205-L217
train
58,656
sdcooke/django_bundles
django_bundles/core.py
get_bundle_versions
def get_bundle_versions(): """ Used to cache the bundle versions rather than loading them from the bundle versions file every time they're used """ global _cached_versions if not bundles_settings.BUNDLES_VERSION_FILE: _cached_versions = {} if _cached_versions is None: locs = {} ...
python
def get_bundle_versions(): """ Used to cache the bundle versions rather than loading them from the bundle versions file every time they're used """ global _cached_versions if not bundles_settings.BUNDLES_VERSION_FILE: _cached_versions = {} if _cached_versions is None: locs = {} ...
[ "def", "get_bundle_versions", "(", ")", ":", "global", "_cached_versions", "if", "not", "bundles_settings", ".", "BUNDLES_VERSION_FILE", ":", "_cached_versions", "=", "{", "}", "if", "_cached_versions", "is", "None", ":", "locs", "=", "{", "}", "try", ":", "ex...
Used to cache the bundle versions rather than loading them from the bundle versions file every time they're used
[ "Used", "to", "cache", "the", "bundle", "versions", "rather", "than", "loading", "them", "from", "the", "bundle", "versions", "file", "every", "time", "they", "re", "used" ]
2810fc455ec7391283792c1f108f4e8340f5d12f
https://github.com/sdcooke/django_bundles/blob/2810fc455ec7391283792c1f108f4e8340f5d12f/django_bundles/core.py#L221-L235
train
58,657
sdcooke/django_bundles
django_bundles/core.py
Bundle.get_url
def get_url(self, version=None): """ Return the filename of the bundled bundle """ if self.fixed_bundle_url: return self.fixed_bundle_url return '%s.%s.%s' % (os.path.join(self.bundle_url_root, self.bundle_filename), version or self.get_version(), self.bundle_type)
python
def get_url(self, version=None): """ Return the filename of the bundled bundle """ if self.fixed_bundle_url: return self.fixed_bundle_url return '%s.%s.%s' % (os.path.join(self.bundle_url_root, self.bundle_filename), version or self.get_version(), self.bundle_type)
[ "def", "get_url", "(", "self", ",", "version", "=", "None", ")", ":", "if", "self", ".", "fixed_bundle_url", ":", "return", "self", ".", "fixed_bundle_url", "return", "'%s.%s.%s'", "%", "(", "os", ".", "path", ".", "join", "(", "self", ".", "bundle_url_r...
Return the filename of the bundled bundle
[ "Return", "the", "filename", "of", "the", "bundled", "bundle" ]
2810fc455ec7391283792c1f108f4e8340f5d12f
https://github.com/sdcooke/django_bundles/blob/2810fc455ec7391283792c1f108f4e8340f5d12f/django_bundles/core.py#L109-L115
train
58,658
sdcooke/django_bundles
django_bundles/core.py
Bundle.get_file_urls
def get_file_urls(self): """ Return a list of file urls - will return a single item if settings.USE_BUNDLES is True """ if self.use_bundle: return [self.get_url()] return [bundle_file.file_url for bundle_file in self.files]
python
def get_file_urls(self): """ Return a list of file urls - will return a single item if settings.USE_BUNDLES is True """ if self.use_bundle: return [self.get_url()] return [bundle_file.file_url for bundle_file in self.files]
[ "def", "get_file_urls", "(", "self", ")", ":", "if", "self", ".", "use_bundle", ":", "return", "[", "self", ".", "get_url", "(", ")", "]", "return", "[", "bundle_file", ".", "file_url", "for", "bundle_file", "in", "self", ".", "files", "]" ]
Return a list of file urls - will return a single item if settings.USE_BUNDLES is True
[ "Return", "a", "list", "of", "file", "urls", "-", "will", "return", "a", "single", "item", "if", "settings", ".", "USE_BUNDLES", "is", "True" ]
2810fc455ec7391283792c1f108f4e8340f5d12f
https://github.com/sdcooke/django_bundles/blob/2810fc455ec7391283792c1f108f4e8340f5d12f/django_bundles/core.py#L122-L128
train
58,659
erikvw/django-collect-offline-files
django_collect_offline_files/transaction/transaction_exporter.py
TransactionExporter.export_batch
def export_batch(self): """Returns a batch instance after exporting a batch of txs. """ batch = self.batch_cls( model=self.model, history_model=self.history_model, using=self.using ) if batch.items: try: json_file = self.json_file_cls(batch...
python
def export_batch(self): """Returns a batch instance after exporting a batch of txs. """ batch = self.batch_cls( model=self.model, history_model=self.history_model, using=self.using ) if batch.items: try: json_file = self.json_file_cls(batch...
[ "def", "export_batch", "(", "self", ")", ":", "batch", "=", "self", ".", "batch_cls", "(", "model", "=", "self", ".", "model", ",", "history_model", "=", "self", ".", "history_model", ",", "using", "=", "self", ".", "using", ")", "if", "batch", ".", ...
Returns a batch instance after exporting a batch of txs.
[ "Returns", "a", "batch", "instance", "after", "exporting", "a", "batch", "of", "txs", "." ]
78f61c823ea3926eb88206b019b5dca3c36017da
https://github.com/erikvw/django-collect-offline-files/blob/78f61c823ea3926eb88206b019b5dca3c36017da/django_collect_offline_files/transaction/transaction_exporter.py#L179-L193
train
58,660
Cadasta/django-jsonattrs
jsonattrs/fields.py
JSONAttributes._check_key
def _check_key(self, key): """ Ensure key is either in schema's attributes or already set on self. """ self.setup_schema() if key not in self._attrs and key not in self: raise KeyError(key)
python
def _check_key(self, key): """ Ensure key is either in schema's attributes or already set on self. """ self.setup_schema() if key not in self._attrs and key not in self: raise KeyError(key)
[ "def", "_check_key", "(", "self", ",", "key", ")", ":", "self", ".", "setup_schema", "(", ")", "if", "key", "not", "in", "self", ".", "_attrs", "and", "key", "not", "in", "self", ":", "raise", "KeyError", "(", "key", ")" ]
Ensure key is either in schema's attributes or already set on self.
[ "Ensure", "key", "is", "either", "in", "schema", "s", "attributes", "or", "already", "set", "on", "self", "." ]
5149e08ec84da00dd73bd3fe548bc52fd361667c
https://github.com/Cadasta/django-jsonattrs/blob/5149e08ec84da00dd73bd3fe548bc52fd361667c/jsonattrs/fields.py#L123-L129
train
58,661
AndrewAnnex/moody
moody/moody.py
ODE.hirise_edr
def hirise_edr(self, pid, chunk_size=1024*1024): """ Download a HiRISE EDR set of .IMG files to the CWD You must know the full id to specifiy the filter to use, ie: PSP_XXXXXX_YYYY will download every EDR IMG file available PSP_XXXXXX_YYYY_R will download every EDR...
python
def hirise_edr(self, pid, chunk_size=1024*1024): """ Download a HiRISE EDR set of .IMG files to the CWD You must know the full id to specifiy the filter to use, ie: PSP_XXXXXX_YYYY will download every EDR IMG file available PSP_XXXXXX_YYYY_R will download every EDR...
[ "def", "hirise_edr", "(", "self", ",", "pid", ",", "chunk_size", "=", "1024", "*", "1024", ")", ":", "productid", "=", "\"{}*\"", ".", "format", "(", "pid", ")", "query", "=", "{", "\"target\"", ":", "\"mars\"", ",", "\"query\"", ":", "\"product\"", ",...
Download a HiRISE EDR set of .IMG files to the CWD You must know the full id to specifiy the filter to use, ie: PSP_XXXXXX_YYYY will download every EDR IMG file available PSP_XXXXXX_YYYY_R will download every EDR RED filter IMG file PSP_XXXXXX_YYYY_BG12_0 will download on...
[ "Download", "a", "HiRISE", "EDR", "set", "of", ".", "IMG", "files", "to", "the", "CWD" ]
07cee4c8fe8bbe4a2b9e8f06db2bca425f618b33
https://github.com/AndrewAnnex/moody/blob/07cee4c8fe8bbe4a2b9e8f06db2bca425f618b33/moody/moody.py#L45-L81
train
58,662
dariusbakunas/rawdisk
rawdisk/plugins/filesystems/ntfs/ntfs.py
Ntfs.detect
def detect(self, filename, offset, standalone=False): """Verifies NTFS filesystem signature. Returns: bool: True if filesystem signature at offset 0x03 \ matches 'NTFS ', False otherwise. """ r = RawStruct( filename=filename, offset=off...
python
def detect(self, filename, offset, standalone=False): """Verifies NTFS filesystem signature. Returns: bool: True if filesystem signature at offset 0x03 \ matches 'NTFS ', False otherwise. """ r = RawStruct( filename=filename, offset=off...
[ "def", "detect", "(", "self", ",", "filename", ",", "offset", ",", "standalone", "=", "False", ")", ":", "r", "=", "RawStruct", "(", "filename", "=", "filename", ",", "offset", "=", "offset", "+", "SIG_OFFSET", ",", "length", "=", "SIG_SIZE", ")", "oem...
Verifies NTFS filesystem signature. Returns: bool: True if filesystem signature at offset 0x03 \ matches 'NTFS ', False otherwise.
[ "Verifies", "NTFS", "filesystem", "signature", "." ]
1dc9d0b377fe5da3c406ccec4abc238c54167403
https://github.com/dariusbakunas/rawdisk/blob/1dc9d0b377fe5da3c406ccec4abc238c54167403/rawdisk/plugins/filesystems/ntfs/ntfs.py#L27-L44
train
58,663
barnybug/finite
finite/dfa.py
Action.load
def load(cls, v): """Load the action from configuration""" if v is None: return [] if isinstance(v, list): return [ Action(s) for s in v ] elif isinstance(v, str): return [Action(v)] else: raise ParseError("Couldn't parse action: %r...
python
def load(cls, v): """Load the action from configuration""" if v is None: return [] if isinstance(v, list): return [ Action(s) for s in v ] elif isinstance(v, str): return [Action(v)] else: raise ParseError("Couldn't parse action: %r...
[ "def", "load", "(", "cls", ",", "v", ")", ":", "if", "v", "is", "None", ":", "return", "[", "]", "if", "isinstance", "(", "v", ",", "list", ")", ":", "return", "[", "Action", "(", "s", ")", "for", "s", "in", "v", "]", "elif", "isinstance", "(...
Load the action from configuration
[ "Load", "the", "action", "from", "configuration" ]
a587fef255dc90377e86ba1449a19070ce910a36
https://github.com/barnybug/finite/blob/a587fef255dc90377e86ba1449a19070ce910a36/finite/dfa.py#L159-L168
train
58,664
barnybug/finite
finite/dfa.py
Loader.load_stream
def load_stream(cls, st): """Load Automatons from a stream""" y = yaml.load(st) return [ Automaton(k, v) for k, v in y.iteritems() ]
python
def load_stream(cls, st): """Load Automatons from a stream""" y = yaml.load(st) return [ Automaton(k, v) for k, v in y.iteritems() ]
[ "def", "load_stream", "(", "cls", ",", "st", ")", ":", "y", "=", "yaml", ".", "load", "(", "st", ")", "return", "[", "Automaton", "(", "k", ",", "v", ")", "for", "k", ",", "v", "in", "y", ".", "iteritems", "(", ")", "]" ]
Load Automatons from a stream
[ "Load", "Automatons", "from", "a", "stream" ]
a587fef255dc90377e86ba1449a19070ce910a36
https://github.com/barnybug/finite/blob/a587fef255dc90377e86ba1449a19070ce910a36/finite/dfa.py#L184-L187
train
58,665
barnybug/finite
finite/dfa.py
Loader.make_dot
def make_dot(self, filename_or_stream, auts): """Create a graphviz .dot representation of the automaton.""" if isinstance(filename_or_stream, str): stream = file(filename_or_stream, 'w') else: stream = filename_or_stream dot = DotFile(stream) ...
python
def make_dot(self, filename_or_stream, auts): """Create a graphviz .dot representation of the automaton.""" if isinstance(filename_or_stream, str): stream = file(filename_or_stream, 'w') else: stream = filename_or_stream dot = DotFile(stream) ...
[ "def", "make_dot", "(", "self", ",", "filename_or_stream", ",", "auts", ")", ":", "if", "isinstance", "(", "filename_or_stream", ",", "str", ")", ":", "stream", "=", "file", "(", "filename_or_stream", ",", "'w'", ")", "else", ":", "stream", "=", "filename_...
Create a graphviz .dot representation of the automaton.
[ "Create", "a", "graphviz", ".", "dot", "representation", "of", "the", "automaton", "." ]
a587fef255dc90377e86ba1449a19070ce910a36
https://github.com/barnybug/finite/blob/a587fef255dc90377e86ba1449a19070ce910a36/finite/dfa.py#L190-L219
train
58,666
RetailMeNotSandbox/acky
acky/s3.py
S3.create
def create(self, url): """Create a bucket, directory, or empty file.""" bucket, obj_key = _parse_url(url) if not bucket: raise InvalidURL(url, "You must specify a bucket and (optional) path") if obj_key: target = "/".join((bucket, ob...
python
def create(self, url): """Create a bucket, directory, or empty file.""" bucket, obj_key = _parse_url(url) if not bucket: raise InvalidURL(url, "You must specify a bucket and (optional) path") if obj_key: target = "/".join((bucket, ob...
[ "def", "create", "(", "self", ",", "url", ")", ":", "bucket", ",", "obj_key", "=", "_parse_url", "(", "url", ")", "if", "not", "bucket", ":", "raise", "InvalidURL", "(", "url", ",", "\"You must specify a bucket and (optional) path\"", ")", "if", "obj_key", "...
Create a bucket, directory, or empty file.
[ "Create", "a", "bucket", "directory", "or", "empty", "file", "." ]
fcd4d092c42892ede7c924cafc41e9cf4be3fb9f
https://github.com/RetailMeNotSandbox/acky/blob/fcd4d092c42892ede7c924cafc41e9cf4be3fb9f/acky/s3.py#L60-L73
train
58,667
RetailMeNotSandbox/acky
acky/s3.py
S3.destroy
def destroy(self, url, recursive=False): """Destroy a bucket, directory, or file. Specifying recursive=True recursively deletes all subdirectories and files.""" bucket, obj_key = _parse_url(url) if not bucket: raise InvalidURL(url, "You must spec...
python
def destroy(self, url, recursive=False): """Destroy a bucket, directory, or file. Specifying recursive=True recursively deletes all subdirectories and files.""" bucket, obj_key = _parse_url(url) if not bucket: raise InvalidURL(url, "You must spec...
[ "def", "destroy", "(", "self", ",", "url", ",", "recursive", "=", "False", ")", ":", "bucket", ",", "obj_key", "=", "_parse_url", "(", "url", ")", "if", "not", "bucket", ":", "raise", "InvalidURL", "(", "url", ",", "\"You must specify a bucket and (optional)...
Destroy a bucket, directory, or file. Specifying recursive=True recursively deletes all subdirectories and files.
[ "Destroy", "a", "bucket", "directory", "or", "file", ".", "Specifying", "recursive", "=", "True", "recursively", "deletes", "all", "subdirectories", "and", "files", "." ]
fcd4d092c42892ede7c924cafc41e9cf4be3fb9f
https://github.com/RetailMeNotSandbox/acky/blob/fcd4d092c42892ede7c924cafc41e9cf4be3fb9f/acky/s3.py#L75-L93
train
58,668
RetailMeNotSandbox/acky
acky/s3.py
S3.upload
def upload(self, local_path, remote_url): """Copy a local file to an S3 location.""" bucket, key = _parse_url(remote_url) with open(local_path, 'rb') as fp: return self.call("PutObject", bucket=bucket, key=key, body=fp)
python
def upload(self, local_path, remote_url): """Copy a local file to an S3 location.""" bucket, key = _parse_url(remote_url) with open(local_path, 'rb') as fp: return self.call("PutObject", bucket=bucket, key=key, body=fp)
[ "def", "upload", "(", "self", ",", "local_path", ",", "remote_url", ")", ":", "bucket", ",", "key", "=", "_parse_url", "(", "remote_url", ")", "with", "open", "(", "local_path", ",", "'rb'", ")", "as", "fp", ":", "return", "self", ".", "call", "(", "...
Copy a local file to an S3 location.
[ "Copy", "a", "local", "file", "to", "an", "S3", "location", "." ]
fcd4d092c42892ede7c924cafc41e9cf4be3fb9f
https://github.com/RetailMeNotSandbox/acky/blob/fcd4d092c42892ede7c924cafc41e9cf4be3fb9f/acky/s3.py#L95-L100
train
58,669
RetailMeNotSandbox/acky
acky/s3.py
S3.download
def download(self, remote_url, local_path, buffer_size=8 * 1024): """Copy S3 data to a local file.""" bucket, key = _parse_url(remote_url) response_file = self.call("GetObject", bucket=bucket, key=key)['Body'] with open(local_path, 'wb') as fp: buf = response_file.read(buffe...
python
def download(self, remote_url, local_path, buffer_size=8 * 1024): """Copy S3 data to a local file.""" bucket, key = _parse_url(remote_url) response_file = self.call("GetObject", bucket=bucket, key=key)['Body'] with open(local_path, 'wb') as fp: buf = response_file.read(buffe...
[ "def", "download", "(", "self", ",", "remote_url", ",", "local_path", ",", "buffer_size", "=", "8", "*", "1024", ")", ":", "bucket", ",", "key", "=", "_parse_url", "(", "remote_url", ")", "response_file", "=", "self", ".", "call", "(", "\"GetObject\"", "...
Copy S3 data to a local file.
[ "Copy", "S3", "data", "to", "a", "local", "file", "." ]
fcd4d092c42892ede7c924cafc41e9cf4be3fb9f
https://github.com/RetailMeNotSandbox/acky/blob/fcd4d092c42892ede7c924cafc41e9cf4be3fb9f/acky/s3.py#L102-L111
train
58,670
RetailMeNotSandbox/acky
acky/s3.py
S3.copy
def copy(self, src_url, dst_url): """Copy an S3 object to another S3 location.""" src_bucket, src_key = _parse_url(src_url) dst_bucket, dst_key = _parse_url(dst_url) if not dst_bucket: dst_bucket = src_bucket params = { 'copy_source': '/'.join((src_bucket...
python
def copy(self, src_url, dst_url): """Copy an S3 object to another S3 location.""" src_bucket, src_key = _parse_url(src_url) dst_bucket, dst_key = _parse_url(dst_url) if not dst_bucket: dst_bucket = src_bucket params = { 'copy_source': '/'.join((src_bucket...
[ "def", "copy", "(", "self", ",", "src_url", ",", "dst_url", ")", ":", "src_bucket", ",", "src_key", "=", "_parse_url", "(", "src_url", ")", "dst_bucket", ",", "dst_key", "=", "_parse_url", "(", "dst_url", ")", "if", "not", "dst_bucket", ":", "dst_bucket", ...
Copy an S3 object to another S3 location.
[ "Copy", "an", "S3", "object", "to", "another", "S3", "location", "." ]
fcd4d092c42892ede7c924cafc41e9cf4be3fb9f
https://github.com/RetailMeNotSandbox/acky/blob/fcd4d092c42892ede7c924cafc41e9cf4be3fb9f/acky/s3.py#L113-L125
train
58,671
RetailMeNotSandbox/acky
acky/s3.py
S3.move
def move(self, src_url, dst_url): """Copy a single S3 object to another S3 location, then delete the original object.""" self.copy(src_url, dst_url) self.destroy(src_url)
python
def move(self, src_url, dst_url): """Copy a single S3 object to another S3 location, then delete the original object.""" self.copy(src_url, dst_url) self.destroy(src_url)
[ "def", "move", "(", "self", ",", "src_url", ",", "dst_url", ")", ":", "self", ".", "copy", "(", "src_url", ",", "dst_url", ")", "self", ".", "destroy", "(", "src_url", ")" ]
Copy a single S3 object to another S3 location, then delete the original object.
[ "Copy", "a", "single", "S3", "object", "to", "another", "S3", "location", "then", "delete", "the", "original", "object", "." ]
fcd4d092c42892ede7c924cafc41e9cf4be3fb9f
https://github.com/RetailMeNotSandbox/acky/blob/fcd4d092c42892ede7c924cafc41e9cf4be3fb9f/acky/s3.py#L127-L131
train
58,672
mishan/twemredis-py
twemredis.py
TwemRedis.get_shard_names
def get_shard_names(self): """ get_shard_names returns an array containing the names of the shards in the cluster. This is determined with num_shards and shard_name_format """ results = [] for shard_num in range(0, self.num_shards()): shard_name = self...
python
def get_shard_names(self): """ get_shard_names returns an array containing the names of the shards in the cluster. This is determined with num_shards and shard_name_format """ results = [] for shard_num in range(0, self.num_shards()): shard_name = self...
[ "def", "get_shard_names", "(", "self", ")", ":", "results", "=", "[", "]", "for", "shard_num", "in", "range", "(", "0", ",", "self", ".", "num_shards", "(", ")", ")", ":", "shard_name", "=", "self", ".", "get_shard_name", "(", "shard_num", ")", "result...
get_shard_names returns an array containing the names of the shards in the cluster. This is determined with num_shards and shard_name_format
[ "get_shard_names", "returns", "an", "array", "containing", "the", "names", "of", "the", "shards", "in", "the", "cluster", ".", "This", "is", "determined", "with", "num_shards", "and", "shard_name_format" ]
cfc787d90482eb6a2037cfbf4863bd144582662d
https://github.com/mishan/twemredis-py/blob/cfc787d90482eb6a2037cfbf4863bd144582662d/twemredis.py#L119-L130
train
58,673
mishan/twemredis-py
twemredis.py
TwemRedis.get_canonical_key_id
def get_canonical_key_id(self, key_id): """ get_canonical_key_id is used by get_canonical_key, see the comment for that method for more explanation. Keyword arguments: key_id -- the key id (e.g. '12345') returns the canonical key id (e.g. '12') """ shard...
python
def get_canonical_key_id(self, key_id): """ get_canonical_key_id is used by get_canonical_key, see the comment for that method for more explanation. Keyword arguments: key_id -- the key id (e.g. '12345') returns the canonical key id (e.g. '12') """ shard...
[ "def", "get_canonical_key_id", "(", "self", ",", "key_id", ")", ":", "shard_num", "=", "self", ".", "get_shard_num_by_key_id", "(", "key_id", ")", "return", "self", ".", "_canonical_keys", "[", "shard_num", "]" ]
get_canonical_key_id is used by get_canonical_key, see the comment for that method for more explanation. Keyword arguments: key_id -- the key id (e.g. '12345') returns the canonical key id (e.g. '12')
[ "get_canonical_key_id", "is", "used", "by", "get_canonical_key", "see", "the", "comment", "for", "that", "method", "for", "more", "explanation", "." ]
cfc787d90482eb6a2037cfbf4863bd144582662d
https://github.com/mishan/twemredis-py/blob/cfc787d90482eb6a2037cfbf4863bd144582662d/twemredis.py#L222-L233
train
58,674
mishan/twemredis-py
twemredis.py
TwemRedis.get_shard_by_num
def get_shard_by_num(self, shard_num): """ get_shard_by_num returns the shard at index shard_num. Keyword arguments: shard_num -- The shard index Returns a redis.StrictRedis connection or raises a ValueError. """ if shard_num < 0 or shard_num >= self.num_shards(...
python
def get_shard_by_num(self, shard_num): """ get_shard_by_num returns the shard at index shard_num. Keyword arguments: shard_num -- The shard index Returns a redis.StrictRedis connection or raises a ValueError. """ if shard_num < 0 or shard_num >= self.num_shards(...
[ "def", "get_shard_by_num", "(", "self", ",", "shard_num", ")", ":", "if", "shard_num", "<", "0", "or", "shard_num", ">=", "self", ".", "num_shards", "(", ")", ":", "raise", "ValueError", "(", "\"requested invalid shard# {0}\"", ".", "format", "(", "shard_num",...
get_shard_by_num returns the shard at index shard_num. Keyword arguments: shard_num -- The shard index Returns a redis.StrictRedis connection or raises a ValueError.
[ "get_shard_by_num", "returns", "the", "shard", "at", "index", "shard_num", "." ]
cfc787d90482eb6a2037cfbf4863bd144582662d
https://github.com/mishan/twemredis-py/blob/cfc787d90482eb6a2037cfbf4863bd144582662d/twemredis.py#L247-L259
train
58,675
mishan/twemredis-py
twemredis.py
TwemRedis._get_key_id_from_key
def _get_key_id_from_key(self, key): """ _get_key_id_from_key returns the key id from a key, if found. otherwise it just returns the key to be used as the key id. Keyword arguments: key -- The key to derive the ID from. If curly braces are found in the key, then t...
python
def _get_key_id_from_key(self, key): """ _get_key_id_from_key returns the key id from a key, if found. otherwise it just returns the key to be used as the key id. Keyword arguments: key -- The key to derive the ID from. If curly braces are found in the key, then t...
[ "def", "_get_key_id_from_key", "(", "self", ",", "key", ")", ":", "key_id", "=", "key", "regex", "=", "'{0}([^{1}]*){2}'", ".", "format", "(", "self", ".", "_hash_start", ",", "self", ".", "_hash_stop", ",", "self", ".", "_hash_stop", ")", "m", "=", "re"...
_get_key_id_from_key returns the key id from a key, if found. otherwise it just returns the key to be used as the key id. Keyword arguments: key -- The key to derive the ID from. If curly braces are found in the key, then the contents of the curly braces are used as the ...
[ "_get_key_id_from_key", "returns", "the", "key", "id", "from", "a", "key", "if", "found", ".", "otherwise", "it", "just", "returns", "the", "key", "to", "be", "used", "as", "the", "key", "id", "." ]
cfc787d90482eb6a2037cfbf4863bd144582662d
https://github.com/mishan/twemredis-py/blob/cfc787d90482eb6a2037cfbf4863bd144582662d/twemredis.py#L261-L284
train
58,676
mishan/twemredis-py
twemredis.py
TwemRedis.compute_canonical_key_ids
def compute_canonical_key_ids(self, search_amplifier=100): """ A canonical key id is the lowest integer key id that maps to a particular shard. The mapping to canonical key ids depends on the number of shards. Returns a dictionary mapping from shard number to canonical key id. ...
python
def compute_canonical_key_ids(self, search_amplifier=100): """ A canonical key id is the lowest integer key id that maps to a particular shard. The mapping to canonical key ids depends on the number of shards. Returns a dictionary mapping from shard number to canonical key id. ...
[ "def", "compute_canonical_key_ids", "(", "self", ",", "search_amplifier", "=", "100", ")", ":", "canonical_keys", "=", "{", "}", "num_shards", "=", "self", ".", "num_shards", "(", ")", "# Guarantees enough to find all keys without running forever", "num_iterations", "="...
A canonical key id is the lowest integer key id that maps to a particular shard. The mapping to canonical key ids depends on the number of shards. Returns a dictionary mapping from shard number to canonical key id. This method will throw an exception if it fails to compute all of ...
[ "A", "canonical", "key", "id", "is", "the", "lowest", "integer", "key", "id", "that", "maps", "to", "a", "particular", "shard", ".", "The", "mapping", "to", "canonical", "key", "ids", "depends", "on", "the", "number", "of", "shards", "." ]
cfc787d90482eb6a2037cfbf4863bd144582662d
https://github.com/mishan/twemredis-py/blob/cfc787d90482eb6a2037cfbf4863bd144582662d/twemredis.py#L286-L315
train
58,677
mishan/twemredis-py
twemredis.py
TwemRedis.keys
def keys(self, args): """ keys wrapper that queries every shard. This is an expensive operation. This method should be invoked on a TwemRedis instance as if it were being invoked directly on a StrictRedis instance. """ results = {} # TODO: parallelize ...
python
def keys(self, args): """ keys wrapper that queries every shard. This is an expensive operation. This method should be invoked on a TwemRedis instance as if it were being invoked directly on a StrictRedis instance. """ results = {} # TODO: parallelize ...
[ "def", "keys", "(", "self", ",", "args", ")", ":", "results", "=", "{", "}", "# TODO: parallelize", "for", "shard_num", "in", "range", "(", "0", ",", "self", ".", "num_shards", "(", ")", ")", ":", "shard", "=", "self", ".", "get_shard_by_num", "(", "...
keys wrapper that queries every shard. This is an expensive operation. This method should be invoked on a TwemRedis instance as if it were being invoked directly on a StrictRedis instance.
[ "keys", "wrapper", "that", "queries", "every", "shard", ".", "This", "is", "an", "expensive", "operation", "." ]
cfc787d90482eb6a2037cfbf4863bd144582662d
https://github.com/mishan/twemredis-py/blob/cfc787d90482eb6a2037cfbf4863bd144582662d/twemredis.py#L336-L349
train
58,678
mishan/twemredis-py
twemredis.py
TwemRedis.mget
def mget(self, args): """ mget wrapper that batches keys per shard and execute as few mgets as necessary to fetch the keys from all the shards involved. This method should be invoked on a TwemRedis instance as if it were being invoked directly on a StrictRedis instance. ...
python
def mget(self, args): """ mget wrapper that batches keys per shard and execute as few mgets as necessary to fetch the keys from all the shards involved. This method should be invoked on a TwemRedis instance as if it were being invoked directly on a StrictRedis instance. ...
[ "def", "mget", "(", "self", ",", "args", ")", ":", "key_map", "=", "collections", ".", "defaultdict", "(", "list", ")", "results", "=", "{", "}", "for", "key", "in", "args", ":", "shard_num", "=", "self", ".", "get_shard_num_by_key", "(", "key", ")", ...
mget wrapper that batches keys per shard and execute as few mgets as necessary to fetch the keys from all the shards involved. This method should be invoked on a TwemRedis instance as if it were being invoked directly on a StrictRedis instance.
[ "mget", "wrapper", "that", "batches", "keys", "per", "shard", "and", "execute", "as", "few", "mgets", "as", "necessary", "to", "fetch", "the", "keys", "from", "all", "the", "shards", "involved", "." ]
cfc787d90482eb6a2037cfbf4863bd144582662d
https://github.com/mishan/twemredis-py/blob/cfc787d90482eb6a2037cfbf4863bd144582662d/twemredis.py#L351-L369
train
58,679
mishan/twemredis-py
twemredis.py
TwemRedis.mset
def mset(self, args): """ mset wrapper that batches keys per shard and execute as few msets as necessary to set the keys in all the shards involved. This method should be invoked on a TwemRedis instance as if it were being invoked directly on a StrictRedis instance. """ ...
python
def mset(self, args): """ mset wrapper that batches keys per shard and execute as few msets as necessary to set the keys in all the shards involved. This method should be invoked on a TwemRedis instance as if it were being invoked directly on a StrictRedis instance. """ ...
[ "def", "mset", "(", "self", ",", "args", ")", ":", "key_map", "=", "collections", ".", "defaultdict", "(", "dict", ")", "result_count", "=", "0", "for", "key", "in", "args", ".", "keys", "(", ")", ":", "value", "=", "args", "[", "key", "]", "shard_...
mset wrapper that batches keys per shard and execute as few msets as necessary to set the keys in all the shards involved. This method should be invoked on a TwemRedis instance as if it were being invoked directly on a StrictRedis instance.
[ "mset", "wrapper", "that", "batches", "keys", "per", "shard", "and", "execute", "as", "few", "msets", "as", "necessary", "to", "set", "the", "keys", "in", "all", "the", "shards", "involved", "." ]
cfc787d90482eb6a2037cfbf4863bd144582662d
https://github.com/mishan/twemredis-py/blob/cfc787d90482eb6a2037cfbf4863bd144582662d/twemredis.py#L371-L391
train
58,680
helixyte/everest
everest/utils.py
id_generator
def id_generator(start=0): """ Generator for sequential numeric numbers. """ count = start while True: send_value = (yield count) if not send_value is None: if send_value < count: raise ValueError('Values from ID generator must increase ' ...
python
def id_generator(start=0): """ Generator for sequential numeric numbers. """ count = start while True: send_value = (yield count) if not send_value is None: if send_value < count: raise ValueError('Values from ID generator must increase ' ...
[ "def", "id_generator", "(", "start", "=", "0", ")", ":", "count", "=", "start", "while", "True", ":", "send_value", "=", "(", "yield", "count", ")", "if", "not", "send_value", "is", "None", ":", "if", "send_value", "<", "count", ":", "raise", "ValueErr...
Generator for sequential numeric numbers.
[ "Generator", "for", "sequential", "numeric", "numbers", "." ]
70c9b93c3061db5cb62428349d18b8fb8566411b
https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/utils.py#L108-L123
train
58,681
helixyte/everest
everest/utils.py
generative
def generative(func): """ Marks an instance method as generative. """ def wrap(inst, *args, **kw): clone = type(inst).__new__(type(inst)) clone.__dict__ = inst.__dict__.copy() return func(clone, *args, **kw) return update_wrapper(wrap, func)
python
def generative(func): """ Marks an instance method as generative. """ def wrap(inst, *args, **kw): clone = type(inst).__new__(type(inst)) clone.__dict__ = inst.__dict__.copy() return func(clone, *args, **kw) return update_wrapper(wrap, func)
[ "def", "generative", "(", "func", ")", ":", "def", "wrap", "(", "inst", ",", "*", "args", ",", "*", "*", "kw", ")", ":", "clone", "=", "type", "(", "inst", ")", ".", "__new__", "(", "type", "(", "inst", ")", ")", "clone", ".", "__dict__", "=", ...
Marks an instance method as generative.
[ "Marks", "an", "instance", "method", "as", "generative", "." ]
70c9b93c3061db5cb62428349d18b8fb8566411b
https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/utils.py#L506-L514
train
58,682
helixyte/everest
everest/utils.py
truncate
def truncate(message, limit=500): """ Truncates the message to the given limit length. The beginning and the end of the message are left untouched. """ if len(message) > limit: trc_msg = ''.join([message[:limit // 2 - 2], ' .. ', message[...
python
def truncate(message, limit=500): """ Truncates the message to the given limit length. The beginning and the end of the message are left untouched. """ if len(message) > limit: trc_msg = ''.join([message[:limit // 2 - 2], ' .. ', message[...
[ "def", "truncate", "(", "message", ",", "limit", "=", "500", ")", ":", "if", "len", "(", "message", ")", ">", "limit", ":", "trc_msg", "=", "''", ".", "join", "(", "[", "message", "[", ":", "limit", "//", "2", "-", "2", "]", ",", "' .. '", ",",...
Truncates the message to the given limit length. The beginning and the end of the message are left untouched.
[ "Truncates", "the", "message", "to", "the", "given", "limit", "length", ".", "The", "beginning", "and", "the", "end", "of", "the", "message", "are", "left", "untouched", "." ]
70c9b93c3061db5cb62428349d18b8fb8566411b
https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/utils.py#L517-L528
train
58,683
ponty/confduino
confduino/boardremove.py
remove_board
def remove_board(board_id): """remove board. :param board_id: board id (e.g. 'diecimila') :rtype: None """ log.debug('remove %s', board_id) lines = boards_txt().lines() lines = filter(lambda x: not x.strip().startswith(board_id + '.'), lines) boards_txt().write_lines(lines)
python
def remove_board(board_id): """remove board. :param board_id: board id (e.g. 'diecimila') :rtype: None """ log.debug('remove %s', board_id) lines = boards_txt().lines() lines = filter(lambda x: not x.strip().startswith(board_id + '.'), lines) boards_txt().write_lines(lines)
[ "def", "remove_board", "(", "board_id", ")", ":", "log", ".", "debug", "(", "'remove %s'", ",", "board_id", ")", "lines", "=", "boards_txt", "(", ")", ".", "lines", "(", ")", "lines", "=", "filter", "(", "lambda", "x", ":", "not", "x", ".", "strip", ...
remove board. :param board_id: board id (e.g. 'diecimila') :rtype: None
[ "remove", "board", "." ]
f4c261e5e84997f145a8bdd001f471db74c9054b
https://github.com/ponty/confduino/blob/f4c261e5e84997f145a8bdd001f471db74c9054b/confduino/boardremove.py#L9-L20
train
58,684
AtomHash/evernode
evernode/classes/load_modules.py
LoadModules.make_route
def make_route(self, route) -> dict: """ Construct a route to be parsed into flask App """ middleware = route['middleware'] if 'middleware' in route else None # added to ALL requests to support xhr cross-site requests route['methods'].append('OPTIONS') return { ...
python
def make_route(self, route) -> dict: """ Construct a route to be parsed into flask App """ middleware = route['middleware'] if 'middleware' in route else None # added to ALL requests to support xhr cross-site requests route['methods'].append('OPTIONS') return { ...
[ "def", "make_route", "(", "self", ",", "route", ")", "->", "dict", ":", "middleware", "=", "route", "[", "'middleware'", "]", "if", "'middleware'", "in", "route", "else", "None", "# added to ALL requests to support xhr cross-site requests\r", "route", "[", "'methods...
Construct a route to be parsed into flask App
[ "Construct", "a", "route", "to", "be", "parsed", "into", "flask", "App" ]
b2fb91555fb937a3f3eba41db56dee26f9b034be
https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/classes/load_modules.py#L36-L51
train
58,685
pbrisk/timewave
timewave/stochasticprocess/base.py
StochasticProcess.diffusion_driver
def diffusion_driver(self): """ diffusion driver are the underlying `dW` of each process `X` in a SDE like `dX = m dt + s dW` :return list(StochasticProcess): """ if self._diffusion_driver is None: return self, if isinstance(self._diffusion_driver, list): ...
python
def diffusion_driver(self): """ diffusion driver are the underlying `dW` of each process `X` in a SDE like `dX = m dt + s dW` :return list(StochasticProcess): """ if self._diffusion_driver is None: return self, if isinstance(self._diffusion_driver, list): ...
[ "def", "diffusion_driver", "(", "self", ")", ":", "if", "self", ".", "_diffusion_driver", "is", "None", ":", "return", "self", ",", "if", "isinstance", "(", "self", ".", "_diffusion_driver", ",", "list", ")", ":", "return", "tuple", "(", "self", ".", "_d...
diffusion driver are the underlying `dW` of each process `X` in a SDE like `dX = m dt + s dW` :return list(StochasticProcess):
[ "diffusion", "driver", "are", "the", "underlying", "dW", "of", "each", "process", "X", "in", "a", "SDE", "like", "dX", "=", "m", "dt", "+", "s", "dW" ]
cf641391d1607a424042724c8b990d43ee270ef6
https://github.com/pbrisk/timewave/blob/cf641391d1607a424042724c8b990d43ee270ef6/timewave/stochasticprocess/base.py#L15-L27
train
58,686
clinicedc/edc-permissions
edc_permissions/historical_permissions_updater.py
HistoricalPermissionUpdater.reset_codenames
def reset_codenames(self, dry_run=None, clear_existing=None): """Ensures all historical model codenames exist in Django's Permission model. """ self.created_codenames = [] self.updated_names = [] actions = ["add", "change", "delete", "view"] if django.VERSION >= (...
python
def reset_codenames(self, dry_run=None, clear_existing=None): """Ensures all historical model codenames exist in Django's Permission model. """ self.created_codenames = [] self.updated_names = [] actions = ["add", "change", "delete", "view"] if django.VERSION >= (...
[ "def", "reset_codenames", "(", "self", ",", "dry_run", "=", "None", ",", "clear_existing", "=", "None", ")", ":", "self", ".", "created_codenames", "=", "[", "]", "self", ".", "updated_names", "=", "[", "]", "actions", "=", "[", "\"add\"", ",", "\"change...
Ensures all historical model codenames exist in Django's Permission model.
[ "Ensures", "all", "historical", "model", "codenames", "exist", "in", "Django", "s", "Permission", "model", "." ]
d1aee39a8ddaf4b7741d9306139ddd03625d4e1a
https://github.com/clinicedc/edc-permissions/blob/d1aee39a8ddaf4b7741d9306139ddd03625d4e1a/edc_permissions/historical_permissions_updater.py#L49-L79
train
58,687
helixyte/everest
everest/resources/attributes.py
is_resource_class_member_attribute
def is_resource_class_member_attribute(rc, attr_name): """ Checks if the given attribute name is a member attribute of the given registered resource. """ attr = get_resource_class_attribute(rc, attr_name) return attr.kind == RESOURCE_ATTRIBUTE_KINDS.MEMBER
python
def is_resource_class_member_attribute(rc, attr_name): """ Checks if the given attribute name is a member attribute of the given registered resource. """ attr = get_resource_class_attribute(rc, attr_name) return attr.kind == RESOURCE_ATTRIBUTE_KINDS.MEMBER
[ "def", "is_resource_class_member_attribute", "(", "rc", ",", "attr_name", ")", ":", "attr", "=", "get_resource_class_attribute", "(", "rc", ",", "attr_name", ")", "return", "attr", ".", "kind", "==", "RESOURCE_ATTRIBUTE_KINDS", ".", "MEMBER" ]
Checks if the given attribute name is a member attribute of the given registered resource.
[ "Checks", "if", "the", "given", "attribute", "name", "is", "a", "member", "attribute", "of", "the", "given", "registered", "resource", "." ]
70c9b93c3061db5cb62428349d18b8fb8566411b
https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/resources/attributes.py#L124-L130
train
58,688
helixyte/everest
everest/resources/attributes.py
is_resource_class_collection_attribute
def is_resource_class_collection_attribute(rc, attr_name): """ Checks if the given attribute name is a collection attribute of the given registered resource. """ attr = get_resource_class_attribute(rc, attr_name) return attr.kind == RESOURCE_ATTRIBUTE_KINDS.COLLECTION
python
def is_resource_class_collection_attribute(rc, attr_name): """ Checks if the given attribute name is a collection attribute of the given registered resource. """ attr = get_resource_class_attribute(rc, attr_name) return attr.kind == RESOURCE_ATTRIBUTE_KINDS.COLLECTION
[ "def", "is_resource_class_collection_attribute", "(", "rc", ",", "attr_name", ")", ":", "attr", "=", "get_resource_class_attribute", "(", "rc", ",", "attr_name", ")", "return", "attr", ".", "kind", "==", "RESOURCE_ATTRIBUTE_KINDS", ".", "COLLECTION" ]
Checks if the given attribute name is a collection attribute of the given registered resource.
[ "Checks", "if", "the", "given", "attribute", "name", "is", "a", "collection", "attribute", "of", "the", "given", "registered", "resource", "." ]
70c9b93c3061db5cb62428349d18b8fb8566411b
https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/resources/attributes.py#L133-L139
train
58,689
seancallaway/laughs
laughs/services/ronswanson.py
get_joke
def get_joke(): """Return a Ron Swanson quote. Returns None if unable to retrieve a quote. """ page = requests.get("http://ron-swanson-quotes.herokuapp.com/v2/quotes") if page.status_code == 200: jokes = [] jokes = json.loads(page.content.decode(page.encoding)) return ...
python
def get_joke(): """Return a Ron Swanson quote. Returns None if unable to retrieve a quote. """ page = requests.get("http://ron-swanson-quotes.herokuapp.com/v2/quotes") if page.status_code == 200: jokes = [] jokes = json.loads(page.content.decode(page.encoding)) return ...
[ "def", "get_joke", "(", ")", ":", "page", "=", "requests", ".", "get", "(", "\"http://ron-swanson-quotes.herokuapp.com/v2/quotes\"", ")", "if", "page", ".", "status_code", "==", "200", ":", "jokes", "=", "[", "]", "jokes", "=", "json", ".", "loads", "(", "...
Return a Ron Swanson quote. Returns None if unable to retrieve a quote.
[ "Return", "a", "Ron", "Swanson", "quote", "." ]
e13ca6f16b12401b0384bbf1fea86c081e52143d
https://github.com/seancallaway/laughs/blob/e13ca6f16b12401b0384bbf1fea86c081e52143d/laughs/services/ronswanson.py#L13-L26
train
58,690
childsish/lhc-python
lhc/misc/tools.py
window
def window(iterable, n=2, cast=tuple): """ This function passes a running window along the length of the given iterable. By default, the return value is a tuple, but the cast parameter can be used to change the final result. """ it = iter(iterable) win = deque((next(it) for _ in repeat(...
python
def window(iterable, n=2, cast=tuple): """ This function passes a running window along the length of the given iterable. By default, the return value is a tuple, but the cast parameter can be used to change the final result. """ it = iter(iterable) win = deque((next(it) for _ in repeat(...
[ "def", "window", "(", "iterable", ",", "n", "=", "2", ",", "cast", "=", "tuple", ")", ":", "it", "=", "iter", "(", "iterable", ")", "win", "=", "deque", "(", "(", "next", "(", "it", ")", "for", "_", "in", "repeat", "(", "None", ",", "n", ")",...
This function passes a running window along the length of the given iterable. By default, the return value is a tuple, but the cast parameter can be used to change the final result.
[ "This", "function", "passes", "a", "running", "window", "along", "the", "length", "of", "the", "given", "iterable", ".", "By", "default", "the", "return", "value", "is", "a", "tuple", "but", "the", "cast", "parameter", "can", "be", "used", "to", "change", ...
0a669f46a40a39f24d28665e8b5b606dc7e86beb
https://github.com/childsish/lhc-python/blob/0a669f46a40a39f24d28665e8b5b606dc7e86beb/lhc/misc/tools.py#L22-L35
train
58,691
xolox/python-update-dotdee
update_dotdee/cli.py
main
def main(): """Command line interface for the ``update-dotdee`` program.""" # Initialize logging to the terminal and system log. coloredlogs.install(syslog=True) # Parse the command line arguments. context_opts = {} program_opts = {} try: options, arguments = getopt.getopt(sys.argv[1...
python
def main(): """Command line interface for the ``update-dotdee`` program.""" # Initialize logging to the terminal and system log. coloredlogs.install(syslog=True) # Parse the command line arguments. context_opts = {} program_opts = {} try: options, arguments = getopt.getopt(sys.argv[1...
[ "def", "main", "(", ")", ":", "# Initialize logging to the terminal and system log.", "coloredlogs", ".", "install", "(", "syslog", "=", "True", ")", "# Parse the command line arguments.", "context_opts", "=", "{", "}", "program_opts", "=", "{", "}", "try", ":", "op...
Command line interface for the ``update-dotdee`` program.
[ "Command", "line", "interface", "for", "the", "update", "-", "dotdee", "program", "." ]
04d5836f0d217e32778745b533beeb8159d80c32
https://github.com/xolox/python-update-dotdee/blob/04d5836f0d217e32778745b533beeb8159d80c32/update_dotdee/cli.py#L65-L111
train
58,692
MisterY/pydatum
pydatum/datum.py
Datum.add_months
def add_months(self, value: int) -> datetime: """ Add a number of months to the given date """ self.value = self.value + relativedelta(months=value) return self.value
python
def add_months(self, value: int) -> datetime: """ Add a number of months to the given date """ self.value = self.value + relativedelta(months=value) return self.value
[ "def", "add_months", "(", "self", ",", "value", ":", "int", ")", "->", "datetime", ":", "self", ".", "value", "=", "self", ".", "value", "+", "relativedelta", "(", "months", "=", "value", ")", "return", "self", ".", "value" ]
Add a number of months to the given date
[ "Add", "a", "number", "of", "months", "to", "the", "given", "date" ]
4b39f43040e31a95bcf219603b6429078a9ba3c2
https://github.com/MisterY/pydatum/blob/4b39f43040e31a95bcf219603b6429078a9ba3c2/pydatum/datum.py#L36-L39
train
58,693
MisterY/pydatum
pydatum/datum.py
Datum.from_date
def from_date(self, value: date) -> datetime: """ Initializes from the given date value """ assert isinstance(value, date) #self.value = datetime.combine(value, time.min) self.value = datetime(value.year, value.month, value.day) return self.value
python
def from_date(self, value: date) -> datetime: """ Initializes from the given date value """ assert isinstance(value, date) #self.value = datetime.combine(value, time.min) self.value = datetime(value.year, value.month, value.day) return self.value
[ "def", "from_date", "(", "self", ",", "value", ":", "date", ")", "->", "datetime", ":", "assert", "isinstance", "(", "value", ",", "date", ")", "#self.value = datetime.combine(value, time.min)", "self", ".", "value", "=", "datetime", "(", "value", ".", "year",...
Initializes from the given date value
[ "Initializes", "from", "the", "given", "date", "value" ]
4b39f43040e31a95bcf219603b6429078a9ba3c2
https://github.com/MisterY/pydatum/blob/4b39f43040e31a95bcf219603b6429078a9ba3c2/pydatum/datum.py#L62-L68
train
58,694
MisterY/pydatum
pydatum/datum.py
Datum.get_day_name
def get_day_name(self) -> str: """ Returns the day name """ weekday = self.value.isoweekday() - 1 return calendar.day_name[weekday]
python
def get_day_name(self) -> str: """ Returns the day name """ weekday = self.value.isoweekday() - 1 return calendar.day_name[weekday]
[ "def", "get_day_name", "(", "self", ")", "->", "str", ":", "weekday", "=", "self", ".", "value", ".", "isoweekday", "(", ")", "-", "1", "return", "calendar", ".", "day_name", "[", "weekday", "]" ]
Returns the day name
[ "Returns", "the", "day", "name" ]
4b39f43040e31a95bcf219603b6429078a9ba3c2
https://github.com/MisterY/pydatum/blob/4b39f43040e31a95bcf219603b6429078a9ba3c2/pydatum/datum.py#L95-L98
train
58,695
MisterY/pydatum
pydatum/datum.py
Datum.to_iso_string
def to_iso_string(self) -> str: """ Returns full ISO string for the given date """ assert isinstance(self.value, datetime) return datetime.isoformat(self.value)
python
def to_iso_string(self) -> str: """ Returns full ISO string for the given date """ assert isinstance(self.value, datetime) return datetime.isoformat(self.value)
[ "def", "to_iso_string", "(", "self", ")", "->", "str", ":", "assert", "isinstance", "(", "self", ".", "value", ",", "datetime", ")", "return", "datetime", ".", "isoformat", "(", "self", ".", "value", ")" ]
Returns full ISO string for the given date
[ "Returns", "full", "ISO", "string", "for", "the", "given", "date" ]
4b39f43040e31a95bcf219603b6429078a9ba3c2
https://github.com/MisterY/pydatum/blob/4b39f43040e31a95bcf219603b6429078a9ba3c2/pydatum/datum.py#L110-L113
train
58,696
MisterY/pydatum
pydatum/datum.py
Datum.end_of_day
def end_of_day(self) -> datetime: """ End of day """ self.value = datetime(self.value.year, self.value.month, self.value.day, 23, 59, 59) return self.value
python
def end_of_day(self) -> datetime: """ End of day """ self.value = datetime(self.value.year, self.value.month, self.value.day, 23, 59, 59) return self.value
[ "def", "end_of_day", "(", "self", ")", "->", "datetime", ":", "self", ".", "value", "=", "datetime", "(", "self", ".", "value", ".", "year", ",", "self", ".", "value", ".", "month", ",", "self", ".", "value", ".", "day", ",", "23", ",", "59", ","...
End of day
[ "End", "of", "day" ]
4b39f43040e31a95bcf219603b6429078a9ba3c2
https://github.com/MisterY/pydatum/blob/4b39f43040e31a95bcf219603b6429078a9ba3c2/pydatum/datum.py#L123-L126
train
58,697
MisterY/pydatum
pydatum/datum.py
Datum.end_of_month
def end_of_month(self) -> datetime: """ Provides end of the month for the given date """ # Increase month by 1, result = self.value + relativedelta(months=1) # take the 1st day of the (next) month, result = result.replace(day=1) # subtract one day result = result ...
python
def end_of_month(self) -> datetime: """ Provides end of the month for the given date """ # Increase month by 1, result = self.value + relativedelta(months=1) # take the 1st day of the (next) month, result = result.replace(day=1) # subtract one day result = result ...
[ "def", "end_of_month", "(", "self", ")", "->", "datetime", ":", "# Increase month by 1,", "result", "=", "self", ".", "value", "+", "relativedelta", "(", "months", "=", "1", ")", "# take the 1st day of the (next) month,", "result", "=", "result", ".", "replace", ...
Provides end of the month for the given date
[ "Provides", "end", "of", "the", "month", "for", "the", "given", "date" ]
4b39f43040e31a95bcf219603b6429078a9ba3c2
https://github.com/MisterY/pydatum/blob/4b39f43040e31a95bcf219603b6429078a9ba3c2/pydatum/datum.py#L128-L137
train
58,698
MisterY/pydatum
pydatum/datum.py
Datum.is_end_of_month
def is_end_of_month(self) -> bool: """ Checks if the date is at the end of the month """ end_of_month = Datum() # get_end_of_month(value) end_of_month.end_of_month() return self.value == end_of_month.value
python
def is_end_of_month(self) -> bool: """ Checks if the date is at the end of the month """ end_of_month = Datum() # get_end_of_month(value) end_of_month.end_of_month() return self.value == end_of_month.value
[ "def", "is_end_of_month", "(", "self", ")", "->", "bool", ":", "end_of_month", "=", "Datum", "(", ")", "# get_end_of_month(value)", "end_of_month", ".", "end_of_month", "(", ")", "return", "self", ".", "value", "==", "end_of_month", ".", "value" ]
Checks if the date is at the end of the month
[ "Checks", "if", "the", "date", "is", "at", "the", "end", "of", "the", "month" ]
4b39f43040e31a95bcf219603b6429078a9ba3c2
https://github.com/MisterY/pydatum/blob/4b39f43040e31a95bcf219603b6429078a9ba3c2/pydatum/datum.py#L139-L144
train
58,699