content
stringlengths
35
416k
sha1
stringlengths
40
40
id
int64
0
710k
import os import json def create_tweet_string(): """ This function analyzes the stored json tweet data to create the long sample text It opens each json file and adds the text of every tweet to a resulting string and then returns that string. This function is called by generate_text.py """ json_files = os.lis...
cfe1376ec6312373c8984dbed1dffafeedc9606a
628,524
import sys def read_option_value(option, default=""): """Read the value of one command line option The option should be specified as a string with the necessary - or -- in front. If that option is not one of the command line arguments, default is returned. If there is a value following the option that va...
d21d6351db23f1256a9eb23ae413ede333370aac
628,525
def getY(line, x): """ Get a y coordinate for a line """ m, c = line y = int((m * x) + c) return y
c98fe2c6c1b6fd6541008681dde0d6a669b50d0a
628,526
import urllib3 def processCallSigns(signs): """Process call signs""" http = urllib3.PoolManager() requests = map( lambda x: http.request('GET', "http://qrzcq.com/call/" + x), signs) return map(lambda x: x.data, requests)
550f9d1b3b0a366d023bec438e45ce98aca5ce43
628,527
def get(a, i): """Retrieve the i-th element or return None""" return a[i] if len(a) > i else None
c8daf6e5d1cbf10d2e9d197e4c9b14e38740045b
628,528
import torch def GetLinear(w): """ Return the weights and bias of the Linear module 'w' as a flattened numpy array. """ return torch.cat([w.weight.data.flatten(), w.bias.data.flatten()],0).numpy()
e705795768dc7ae054143061b4aaf1ac63f8182a
628,529
import re def get_signature(source, start): """ Get function signature and process it """ match = re.search(r'c?p?def.+\(', source[start].strip()) if not match: return start_j = match.span()[1] open_brackets = 1 new_sign = match.group() for i in range(start, len(source)): ...
fbe542ec97e3b19e258833ac5c8262a42f6a31df
628,531
def my_replace(my_string, my_old_letter, my_new_letter): """Replaces in a given string all instances of a given letter with another given letter. Keyword arguments: my_string (string) -- Given string. my_old_letter (char) -- Given letter to be replaced. my_new_letter (char) -- Given...
21cbcfdf98b18928a1dca8d5e4ee2be11b528aa4
628,533
def adjust_detector_position(final_detector_length, requested_distance_to_tls, lane_length): """ Adjusts the detector's position. If the detector's length and the requested distance to TLS together are longer than the lane itself, the positio...
eb1cfaa3ec4bd6a5d981b61f971aeb80d3b71f3c
628,534
import os def get_subfiles(directory): """ Returns list of immediate subfiles of a directory """ file_paths = [] for path, subdirs, files in os.walk(directory): for name in files: file_paths.append(os.path.join(path, name)) return file_paths
c154a60c2e2bc8f5c706847f838331393e4b6db3
628,535
def rearange(buf): """ Rearanges the buffer from an x,y image to the actual pixel position """ # buf will be an bytearray with length x*y and contains tuple with 3 items # Need to put all columns from 8 to 15 at the end # # And swap every second line nbuf = [] for c, i in enumerate...
2d3bd2eef0e07dac2e259e1334e3e9a70c868686
628,536
def pow_operator(): """**: Power operator.""" class _Operand: def __pow__(self, other): return "powefull {}".format(other) return _Operand()**'electro'
739f0af75efa7f708011bd768b4a0afce2ba7aaa
628,537
def interpolatePercentCover(percentDatePrev, percentDateAfter, percentCoverPrev, percentCoverAfter, cutDate): """ inputs: percentDatePrev - date obj - date prior to cut date that recorded the percent cover percentDateAfter - date obj - date after the cut date that recorded the percent cover ...
485471021c15f2cdc10bc65e56591c9824ad5572
628,538
def filter_by_lines(units, lines): """Filter units by line(s).""" return [i for i in units if i.line in lines]
d32103055115d078af1237b9d7d2c6fca57b187c
628,539
def validate_percentage(form): """ Functions checks, whether percentage is valid. If not, portfolio gets equally weighted. :param form: :return: form validated """ len_percentage = len(form['percentage']) len_symbol = len(form['symbol']) # check if all given numbers are greater than 0 ...
2cd67cb314c7e8c02f7ddb7fd0e93189c1af132a
628,541
import argparse import os import errno def _run_cli_parser(): """Setup the CLI parser. """ parser = argparse.ArgumentParser() parser.add_argument( "--outfmt", required=False, default="json", help="yaml or json" ) parser.add_argument("--indir", required=False, help="input directory") ...
7d488f1dcc39a598084fc087a240c263cc073492
628,542
def lower_case(s: str) -> str: """Transforms an input string into its lower case version. Args: s: Input string. Returns: (str): Lower case of 's'. """ return s.lower()
73ebf662722ae5900f1f621dbf3ea09472f49be0
628,543
def read_text(filename): """ filename: string, name of file to read Returns a string containing all file contents """ in_file = open(filename, 'r') line = in_file.read() return line
a8219008996a696f61f3fa35ccac3f68b272162e
628,544
import os import functools def os_nice(value): """Return a function for adding a nice value to a process. Args: value: boolean, integer, or string, boolean used to determine the nice increment value. value nice command None nice -n 0 True...
573f54fa82f71690f5e980dd3b6699fd5c7625c8
628,546
def open_input(input_path: str) -> list[str]: """Opens and sanitizes the `input.txt` file for the day reading in each line as an element of a list. - Remove any extra lines at the end of the input files (if present, due to auto-formatting) - Remove newline characters for individual element strings - St...
5b78f7d64d076bd1ed8b6ed1839aaaa45c48e001
628,547
from typing import Any def _convert_to_values_cache( all_device_data: dict[str, Any] ) -> dict[str, dict[str, dict[str, Any]]]: """Covert all device data o separated value list.""" values_cache: dict[str, dict[str, dict[str, Any]]] = {} for device_adr, value in all_device_data.items(): device_...
b9839a3b7373a65559dd8fcbda09fc3deb9d188e
628,548
import re def match_pattern(pattern, value): """ Helper function to carry out pattern matching """ patt = re.compile(pattern) match = patt.match(value) return match is not None
1e29ba068727bb73aa47ecb07f9766cd6fdb2a91
628,549
def match_id(dis_id): """Match a discord id depending on mention or raw ID""" # ID is user mention or role mention if any(x in dis_id for x in ["<@!", "<@&"]): if len(dis_id) == 22: return int(dis_id[3:-1]) # Simple mention elif "<@" in dis_id: if len(dis_id) == 21: ...
476e36d4c9e5a6fbeff379fb8d290489fdda376b
628,550
from typing import TextIO from typing import Dict from typing import OrderedDict import yaml def yaml_load(stream: TextIO) -> Dict[str, str]: """ Load a yaml from a file pointer in an ordered way. :param stream: the file pointer :return: the yaml """ # for pydocstyle def ordered_load(stre...
5523eb373c870820e6e2ca35f2083597be34a2c9
628,551
def BoringCallers(mangled, use_re_wildcards): """Return a list of 'boring' function names (optinally mangled) with */? wildcards (optionally .*/.). Boring = we drop off the bottom of stack traces below such functions. """ need_mangling = [ # Don't show our testing framework: ("testing::Test::Run", ...
86715e6ae4f50fa3e295ac1f086861ffe994afc3
628,552
import os import hashlib def _check_file(fname): """ Method borrowed from https://github.com/fastai/fastai/blob/master/fastai/datasets.py :param fname: :return: """ size = os.path.getsize(fname) with open(fname, "rb") as f: hash_nb = hashlib.md5(f.read(2 ** 20)).hexdigest() ...
5972da41084240bd3e857e9c82944b33395b72e8
628,553
import numpy def return_MST_elongation(distance_arr): """Function estimates the elongation of the MST that is described by the given distance array. The input distance array represents the distances of each node in the graph from the root of the graph (the starting point). Funciton calculates the elonga...
e93b2a0156c55124fe388fe4d2ac328f17f3cc7d
628,557
import fileinput import traceback def replace_string_in_file(file_name, dir_path, source_str, target_str): """ Replace a string in a file. Parameters: file_name (string): file name dir_path (string): root path which file contains source_str (str...
6810349116e3c050c090ff0760a071a14deb6a3f
628,558
import os def get_credentials(): """Returns a creds dictionary filled with parsed from env Keystone API version used is 3; v2 was deprecated in 2014 (Icehouse). Along with this deprecation, environment variable 'OS_TENANT_NAME' is replaced by 'OS_PROJECT_NAME'. """ creds = {'username': os.env...
45a36fb68e2450dbd484b63c2328055abba51f76
628,559
def get_completed_only(mxml_df): """ Filter only completed activities """ complete = mxml_df[mxml_df.EventType == "complete"].rename({ "Timestamp": "Timestamp_Complete" }, axis=1).set_index(["TraceId", "WorkflowModelElement"]) return complete.drop(["Originator", "EventType"], e...
8da852d6cbd1bb915581a53d05501b495e50faaf
628,560
from typing import Dict from typing import Set from typing import Tuple from typing import List def get_list_know_function(relations: Dict[str, Dict[str, Set[str]]]) -> Tuple[List[str], Dict[str, str]] : """Returns a list with all the functions discovered on the source files.""" list_know_functions = list() ...
74fa898a7bfc325e310439be137d787828014251
628,561
def better_brute_force_mscs(seq: list) -> tuple: """Brute-force approach to compute the sum of all subsequences of seq. There are n + (n - 1) + (n - 2) + ... + 1 different subsequences. Time complexity: O(n²).""" _sum = _max = seq[0] start = end = 0 for i in range(0, len(seq)): _sum ...
7ffd5294854bf6b06cce86dc3d55a93a9ca98862
628,562
def get_test_images_dir(): """Gets the path of the test_image_dir""" test_images_dir = "dataset_scripts/tests/testDataset" return test_images_dir
07f306faebc08453c821abcf7828f026964c09b1
628,563
import random def max_vote(votes): """Manual bilding of counts and selection randomly the max vote (count) in the case of a tie.""" counts = {} for vote in votes: if vote in counts.keys(): counts[vote] += 1 else: counts[vote] = 1 # print(counts) # Building t...
993a52b4dd5a1c68d6c652a668b698acfcd4f22e
628,564
from typing import Any import requests def api_call(method: str, endpoint: str, payload: Any = None): """Runs an API call to Transact API Args: method (str): HTTP method endpoint (str): url endpoint (see documentation) payload (Dict[str, Union[str, int, float]], optional): Data payloa...
a66038af2defe7cdd1fcc88a843d4a7b45175c1d
628,566
def remove_file_prefix(file_path, prefix): """ Remove a file path prefix from a give path. leftover directory separators at the beginning of a file after the removal are also stripped. Example: '/remove/this/path/file.c' with a prefix of: '/remove/this/path' becomes: ...
11f1e4929ed94607c5f1aedfe2600e295b4b1e67
628,567
from typing import Iterable from typing import Optional from typing import List from typing import Any import json def concatenate_json_lists(input_files: Iterable[str], output_file: Optional[str] = None ) -> List[Any]: """ Given a list of JSON files that ...
a883678bd7cfa764b95f53f958e0efae34129218
628,568
import os import uuid def authorize_url(client_id=None, redirect_uri=None, state=None, scopes=None, show_dialog=False, http_client=None): """ Trigger authorization dialog :param str client_id: Client ID :param str redirect_uri: Application Redirect URI :param str state: Application State :par...
5a91679b905bacd55b9ddf41e521f3cc176b9476
628,569
from typing import List def bands_union(*args: List[str]) -> List[str]: """Take union of given lists/sets of bands""" bands = [] for arg in args: for a in arg: if a not in bands: bands.append(a) return bands
e65c14134311d044d996bd57e23cbb05b4c2f052
628,570
from typing import Optional import importlib def _get_optional_dependency_version(import_path: str) -> Optional[str]: """Attempts to retrieve the version of an optional dependency Args: import_path: The import path of the dependency. Returns: The version of the dependency if it can be im...
8737d5b26bf9a75b500c7f0b6840715d3ee50069
628,571
def find_weather_emoji(weather_icon): """ Given the `icon` description, finds a suitable emoji to represent weather conditions, and returns it. Currently accepted values (more may be defined in the future): clear-day, clear-night, rain, snow, sleet, wind, fog, cloudy, partly-cloudy-day, partly-cloudy-ni...
e26e54f35974019a654dc133f4568dadded6c91e
628,572
def with_end_char_ex(text, char): """ Description: Append an after character to a text. ( Exclusive for core json to html conversion process) :param text: raw text :param char: character to put :return: Appended Text (e.g. with_end_char("Accounts", ":")-> "Accounts:") """ return str("")....
9a66e84228bfe909b5e61964224bf3510de04b20
628,574
def complete_with_zeros(signal, final_size, idx): """ # Complete with zeros Args: signal (list): signal list final_size (int): size of list idx (int): interaction number Returns: list: list with the final_size and with zeros """ for i in range(idx): signal.a...
f5928e2977fe80d25e3762a5bc5e54f7cb31b83b
628,575
import six def urlpathjoin(*parts): """Join multiple paths into a single url >>> urlpathjoin('https://storage.scrapinghub.com:8002/', 'jobs', '1/2/3') 'https://storage.scrapinghub.com:8002/jobs/1/2/3' >>> urlpathjoin('https://storage.scrapinghub.com:8002', 'jobs', '1/2/3', None) 'https://storage....
9f4598de005b047479a6efe420b854460cf9c2fb
628,576
def has_precedence(op1, op2): """ :param op1: first operator token :param op2: second operator token :return: True if op1 takes precedence over op2, else False. "+" with "-", and "*" with "/" are the same precedence and return False. """ precedence = {"+": 0, "-": 0, "*": 1, "/": 1, "^": 2} ...
3075663daee1775042d0f832fab8158bc720ebeb
628,577
def generate_item(): """Generates a JSON object to then manipulate Args: None Returns: Object: to create an item """ return { "project": -1, "itemType": 33, # Default is a text item "childItemType": 0, "location": { "parent": { "i...
481e309d70bc94d0ba0733aaf0e7e0caa451334c
628,578
def descending_order(num): """ Your task is to make a function that can take any non-negative integer as a argument and return it with its digits in descending order. Essentially, rearrange the digits to create the highest possible number. :param num: an positive integer. :return: the integers digit...
8b4de90f9702befdaa21b1ac6593e29e27ce1571
628,579
def subtree_leaf_positions(subtree): """Return tree positions of all leaves of a subtree.""" relative_leaf_positions = subtree.treepositions('leaves') subtree_root_pos = subtree.treeposition() absolute_leaf_positions = [] for rel_leaf_pos in relative_leaf_positions: absolute_leaf_positions.a...
e8cda95cf2be394418e144130612667acd37e1d5
628,580
def _get_file_as_string(path): """Get the contents of the file as a string.""" with open(path, 'r') as f: data = f.read() return data
83864be3b24a5d21113aababe134fc86886bc083
628,581
def get_transceiver_description(sfp_type, if_alias): """ :param sfp_type: SFP type of transceiver :param if_alias: Port alias name :return: Transceiver decsription """ if not if_alias: description = "{}".format(sfp_type) else: description = "{} for {}".format(sfp_type, if_ali...
636844e09ffd591972fd067c6345c3aeb7da3da8
628,582
def seq_2_features(seq, indices): """converts a single sequence to a list of features based on indices """ result = [] for idxs in indices: feature = ''.join([seq[i] for i in idxs]) result.append(feature) return result
1eb30dad05c9e156634d2d466f6f7dcefeba57c0
628,583
def test_paper_doubles(root, printerror=False): """Verifies if the Lattes CV contains papers with duplicate titles. Args: root: the Lattes CV that has been parsed with the ElementTree language. flag: if 0, then the Lattes CV contains papers with duplicate titles. If 1, the Lattes...
81a6e17fc6a4450c069b830687a7142469f2c592
628,584
def _ondemand(f): """Decorator to only request information if not in cache already. """ name = f.__name__ def func(self, *args, **kwargs): if not args and not kwargs: if hasattr(self, '_%s' % name): return getattr(self, '_%s' % name) a = f(self, *args, *...
ffee612ff8ec74bf5b2fe53fd3758c337d15defc
628,585
def merge_dictionaries(base, primary): """ :param base: dictionary to replace values with :param primary: dictionary whose values we care about most :return: merged dictionary """ # create the dictionary if we pass a None base = base or {} primary = primary or {} merged = base.copy(...
a85babe890413d37bbe9f9830b76c9d45afe2e6b
628,587
def string_builder_variant(request): """Whether to test the chunked or continuous implementation.""" return request.param
2716348e2d0d42c98b0ba5889d70265da3b572f8
628,588
import os import glob def prepare_data(train_mode, dataset="Train"): """ This method prepares data paths of frames used for data preparation. Data paths in each sequence are sorted based on number in the frame's file name. Inputs: train_mode: 0-6 dataset: prepares...
992c3640fdd99aea19b24c98affb681408c07695
628,589
import subprocess def cli(skip_init, path): """Runs flake8 against the code base. Parameters ---------- skip_init : bool Whether to skip init files for flaking path : str, optional Test coverage path, by default sanantonioscientist Returns ------- int Shell ex...
c56ac508cc42c4b69e9b881f493afdee14f97bd6
628,590
import pathlib from typing import Iterable def is_covered(path: pathlib.Path, sources: Iterable[pathlib.Path]) -> bool: """ Checks if `path` is contained in any of the subdirectories in sources. See the test cases for details. """ path = path.resolve() abs_path = [source.resolve() for source i...
72fdb6ff957f66d081cf7fc2a790780c14713e28
628,591
import requests def https_check(website): """Checks http resources""" try: result = requests.get(website, verify=False) except: print(website) return "na" return result.status_code
94efddcd1012705f9b1c108eeea2aba43464b8ae
628,592
def headloss(ffactor, tubelength, tubediameter, flowrate): """Returns the head loss for the mixing pump. #Inputs: #ffactor : Friction factor ; . # tubelength : total tube length per m2 ; m #rhosuspension : Density of the culture suspension ; kg.m-3 #tubediameter : Tube diamete...
fdab183b7a1813ca27c83de1f5d360cb034724e6
628,593
def exists(env): """ Check if `cflow` tool is imported in the environment """ return env['CFLOW'] if 'CFLOW' in env else None
f4e5bffee7a1311a7b02379eba31ac668ce6252d
628,594
import os def recursive_search(root, pattern): """Looks for a particular directory pattern within a directory tree. Ignores files and git directories. Returns: the containing directory of the match or None if not found. """ search_queue = [root] while search_queue: # List the children. curr...
adca5a2864c05c8dbaa449b3c4ed2800688c092c
628,595
def solve(captcha): """Solve captcha. :input: captcha string :return: sum of all paired digits that match >>> solve('1212') 6 >>> solve('1221') 0 >>> solve('123425') 4 >>> solve('123123') 12 >>> solve('12131415') 4 """ a = len(captcha) // 2 return sum(i...
edd3b556db7bb22ea9180c93bb4e5043ce884283
628,596
import os def is_conllu(path): """Determines if the file is in CoNLL-U format.""" return os.path.splitext(path.lower())[1] == ".conllu"
9595d031c3b3df98e792b1e81ab22976fcae813c
628,597
def check_input(letter: str) -> bool: """ Author: Jeremy Trendoff Returns the validity of an input. Takes a str parameter representing the input. >>> check_input('t') True >>> check_input('z') False """ # A list representing the valid inputs vaild_inputs = ['2', '3', 'x'...
59876cddbd6871bdc1e3ceac2633b7e7d3a87809
628,598
import math def theil_l_index(distribution): """Theil's L Index is sensitive to differences at the lower end of the distribution (small incomes). Args: distribution (list): wealth distribution of the population Returns: (float): Theil's L Index (TL), inequality of wealth distribution...
577a7bd9f264093f31f8b99cf1a5f9cc5c11e01b
628,599
def getReverseConnectivity(connectivity): """getReverseConnectivity(connectivity) --> resort connectivity dict with nodes as keys""" reverseConnectivity = {} for el, conn in connectivity.items(): for node in conn: if node not in reverseConnectivity.keys(): reverseC...
c41252f084caa1d86cd1ecbc54b2664e1ed513f2
628,600
import functools def require_privmsg(message=None): """Decorate a function to only be triggerable from a private message. If it is triggered in a channel message, `message` will be said if given. """ def actual_decorator(function): @functools.wraps(function) def _nop(*args, **kwargs):...
9477b91f74d651e7c4eccae8e17dafddc996316a
628,601
def manage_addDateRangeIndex(self, id, extra=None, REQUEST=None, RESPONSE=None, URL3=None): """Add a date range index to the catalog, using the incredibly icky double-indirection-which-hides-NOTHING. """ return self.manage_addIndex(id, 'DateRangeIndex', extra, ...
63c5d406b5f2e53d8a67e3b66ca02441b106a603
628,602
def to_yy(year): """Returns the last 2 digits of the year.""" return str(year % 100).zfill(2)
1b076d0dc9e1db711b59bc787d10bc833ab12868
628,603
def ts_wavecal(pixels,tserSim=False, obsFilter='F444W',subarray='SUBGRISM64',grism='GRISM0'): """ Simple analytic wavelength calibration for NIRCam grism time series """ disp = -0.0010035 ## microns per pixel (toward positive X in raw detector pixels, used in pynrc) undevWav = 4.0 ## ...
3bfb1e8394187c7fab94454f160b3a963dc5b96a
628,606
import numpy def pitch(ax, ay, az): """Angle of x-axis relative to ground (theta) Args ---- ax: ndarray x-axis acceleration values ay: ndarray y-axis acceleration values az: ndarray z-axis acceleration values Returns ------- pitch: ndarray Pitch an...
84220d14efc5db1d316d144a47c7fde7da129467
628,607
import os import json def read_user_config_file(): """ Description: read_user_config_file is responsible for reading user .config.json file Parameters: Takes no paramenters: None:None return: returns usertype of String type: usert...
3d627073b2b24efa3aaf4fbd5d2cee4deeaad000
628,608
def change(seq, start, end, change): """Return the sequence with ``seq[start:end]`` replaced by ``change``""" return seq[:start] + change + seq[end:]
56c7ed60ff36698cb27f62a5d85a3dc249ac9f33
628,610
def vsh_steiber(gr, sand_line, shale_line): """ Apply Steiber (1970) equation to correct Gamma Ray index Vshale values. """ shale_line = float(shale_line) sand_line = float(sand_line) vsh_grindex = (gr - sand_line)/(shale_line - sand_line) vsh_steiber = vsh_grindex/(3.0 - 2.0*v...
cabbaf93b9c5bd0604e3d2066bb5cb03fddff0d4
628,611
def beta_word(beta: float) -> str: """Describe a beta Parameters ---------- beta : float The beta for a portfolio Returns ---------- str The description of the beta """ if abs(1 - beta) > 3: part = "extremely " elif abs(1 - beta) > 2: part = "ver...
5a1830e13bdaae27d4481e0414ede36f1406c992
628,612
from typing import List import importlib def instanciate_classes(modules: dict, module_root) -> List: """ Creates sources based on the config file where each key is a module and each subkey is a class Each class can also have custom configurations when creating an instance :param modules: dictionary w...
9c0e249234b62556691a4e8b71387f67780ff1e5
628,613
import os def is_travis(): """Predicate to determine if the test is running in the context of Travis.""" return "TRAVIS" in os.environ and os.environ["TRAVIS"] == "true"
41c832bbf78ea76b83e5353d8454ec368ee915e5
628,614
def field_max(odb, result): """ Look for the max value in a field output. Scan a field output on an abaqus result database and return the maximum value Parameters ---------- odb : class Abaqus model containing the field results result : class Field output result to search f...
509cc18b13ccea7a354022d008d6fa975f071d21
628,615
import os import shutil def clean_proj_folder(dir, name): """Delete all project name-related folders. Parameters ---------- dir : str Full path to the project directory name : str Name of the project. Returns ------- bool ``True`` when successful, ``False`` wh...
986eff80105e747e307763b160b6e48902179136
628,616
def exp_points(df): """ Calculates expected points for home and away team """ df["H_Pts_Exp"] = 3 * df["H_prob_odds"] + 1 * df["D_prob_odds"] df["A_Pts_Exp"] = 3 * df["A_prob_odds"] + 1 * df["D_prob_odds"] return df
2dc8fbd3c76442aacf91b0e9fd6cd9e96d2678ab
628,617
import requests from bs4 import BeautifulSoup def get_soup_web(path): """ Return the soup object of the url passed as argument.""" url = path r = requests.get(url) r_html = r.text soup = BeautifulSoup(r_html, "html.parser") return soup
26b98b3aacf4ed4f0bba252614f222cfa1b83ab3
628,618
import os def get_version(): """ Get version from context . Retrieves version from the environment variable VERSION. Raise: Exception: Raised if environment variable VERSION is not set. """ if 'VERSION' not in os.environ: raise Exception("Environment variable VERSION must be...
8aa29881644482e3a1a9512c236f6498d561f9d8
628,619
def split_sections(record): """Split record to LOCUS, VERSION, FEATURES and ORIGIN sections""" ret = {'LOCUS': [], 'VERSION': [], 'FEATURES': [], 'ORIGIN': []} keywords = ['LOCUS', 'DEFINITION', 'ACCESSION', 'VERSION', 'KEYWORDS', 'SOURCE', 'REFERENCE', 'FEATURES', 'ORIGIN'] key = '' for line in re...
e5d1103ba9f2657f0e3c6557dd6aa9b5d18357aa
628,620
import re def change_lib_version(lib_path): """ 修改lib版本号为local格式的版本号,输出格式为"0.0.0.0-local_version-local" :param lib_path: :return: """ build_file_path = lib_path + '/build.gradle' fp = open(build_file_path, 'r+') content = fp.read() version_reg = re.compile('NEXUS_DEPLOY_VERSION = ...
00d25a23a32fc810262c3999f68053ec1dd59cd3
628,621
import hashlib def make_password(password): """生成用户的加密后的密码,默认采用md5算法 :param password 明文的密码 :return md5加密后的密文密码""" return hashlib.md5(password).hexdigest()
8191d5b433783ae5e61cece6b5d4c671704013b9
628,623
def find_ultimate_dependency(cache, deps): """Find any one manually-installed package that ultimately caused at least one of the given deps to be installed. Returns "" if none found. """ depchain = {dep: dep for dep in deps} while depchain: newchain = {} for dep, path in depchain.items(): for parent in cach...
4867de97d2e097793931063a5319762324875786
628,624
def get_conv_fname(fname: str, dest_ext: str, output_dir=None) -> str: """Returns the filename and path of the file after conversion Arguments: fname -- the original filename dest_ext -- the extension of the destination file output_dir -- the output directory of the operation """ if output...
33e12ae11ec9f0e72f8ccefd0546fb3751b2bec9
628,625
def applyDictionaryToContent(content, series_dict): """------------------------------------------------------------------- Function: [applyDictionaryToContent] Description: Applies the designated series dictionary to the given story content Input: [series_abbr] The abbreviation of the series [cont...
a3ff0c486b37f195f664b36c981b9af251be7ab5
628,626
def keffLineParse(keffLine): """ Parses through the anaKeff line in .res file. @ In, keffLine, string, string from .res file listing IMPKEFF @ Out, keffTuple, list, (mean IMPKEFF, sd of IMPKEFF) """ newKeffLine = keffLine[keffLine.find('='):] start = newKeffLine.find('[') end = newKeffLine.find(']...
518adf5fe33d9c692d588ec0b9469872b39690aa
628,627
import os import tempfile def get_default_test_tmpdir(): """Returns default test temp dir.""" tmpdir = os.environ.get('TEST_TMPDIR', '') if not tmpdir: tmpdir = os.path.join(tempfile.gettempdir(), 'absl_testing') return tmpdir
61f9f51c7d803b1c57c4ff29654975675b94c377
628,628
def from_dataframe(df): """Turn a dataframe into a dictionary of columns, suitable writing.""" index = {} for column in df.columns: values = df[column].values if(values.dtype == "object"): index[column] = values.tolist() else: index[column] = values retu...
1335a641c86a77f034dc379f68cc8dd5e966cbdf
628,630
def index_sites(structure, species=None, labels=None): """ Return a list of the site indices in a structure that are occupied by specie or label (or both) Args: - structure (Structure): pymatgen structure object - species ({str}): site species to count - label ({str}): sit...
67d5bfb08775318b7d50e7c972f6a1ec34dd063e
628,632
def url_len(url): """ Counting URL without considering '.' """ # Total count for characters in URL w/o '.' char. count = 0 for char in url: if '.' in char: pass else: count += 1 # Return INT return count
2912fb11c9da1ef3ef23b32cb9fdf297eea40e59
628,633
def getHttpStatusCode(v): """Return HTTP response code as integer, e.g. 204.""" if hasattr(v, "value"): return int(v.value) # v is a DAVError else: return int(v)
46baff7894765f252d1447611c6662cb388880db
628,634
def calc_type(a: int, b: int, res: int) -> str: """Find the calculation type by the result. Examples: >>> assert calc_type(10, 2, 5) == 'division' """ return { a - b: 'subtraction', a + b: 'addition', a / b: 'division', a * b: 'multiplication', }[res]
7d9477a4a54df0d8d048358863fa5791a99d549d
628,635
def get_known_topic_tree_extractor_name_list(): """Returns known topic tree extractor names """ known_name_list = [ 'cvs', 'html', ] return known_name_list
94302b0744134373784aaa47a4b9b3960e1703f7
628,637
import json def get_sns_msg(event): """Returns a message object extracted from AWS SNS event. :param event: AWS event object :type event: dict :returns: JSON serialized SNS message object :rtype: dict """ return json.loads(event['Records'][0]['Sns']['Message'])
9263eb930ebec6b0cb0ee601ae1f23e03cf6780b
628,638
def dfs_visited_re(node, graph, visited=[]): """DFS: Return visited nodes via recursion""" for child in graph[node]: if child not in visited: visited.append(child) dfs_visited_re(child, graph, visited) return visited
140c039be8eb59ee2334420fe07ba959f29f4088
628,639
import json def convert_json_to_dict(filename): """ Convert json file to python dictionary """ with open(filename, 'r') as JSON: json_dict = json.load(JSON) return json_dict
11f8ea6d4999a204b9d239afde1aa7538d262208
628,640