Search is not available for this dataset
text
stringlengths
75
104k
def queryGitHubFromFile(self, filePath, gitvars={}, verbosity=0, **kwargs): """Submit a GitHub GraphQL query from a file. Can only be used with GraphQL queries. For REST queries, see the 'queryGitHub' method. Args: filePath (str): A relative or absolute path to a file conta...
def queryGitHub(self, gitquery, gitvars={}, verbosity=0, paginate=False, cursorVar=None, keysToList=[], rest=False, requestCount=0, pageNum=0): """Submit a GitHub query. Args: gitquery (str): The query or endpoint itself. Examples: query: 'query { view...
def _submitQuery(self, gitquery, gitvars={}, verbose=False, rest=False): """Send a curl request to GitHub. Args: gitquery (str): The query or endpoint itself. Examples: query: 'query { viewer { login } }' endpoint: '/user' ...
def _awaitReset(self, utcTimeStamp, verbose=True): """Wait until the given UTC timestamp. Args: utcTimeStamp (int): A UTC format timestamp. verbose (Optional[bool]): If False, all extra printouts will be suppressed. Defaults to True. """ resetTim...
def _countdown(self, waitTime=0, printString="Waiting %*d seconds...", verbose=True): """Makes a pretty countdown. Args: gitquery (str): The query or endpoint itself. Examples: query: 'query { viewer { login } }' endpoint: '/user' ...
def fileLoad(self, filePath=None, updatePath=True): """Load a JSON data file into the internal JSON data dictionary. Current internal data will be overwritten. If no file path is provided, the stored data file path will be used. Args: filePath (Optional[str]): A relative or...
def fileSave(self, filePath=None, updatePath=False): """Write the internal JSON data dictionary to a JSON data file. If no file path is provided, the stored data file path will be used. Args: filePath (Optional[str]): A relative or absolute path to a '.json' file. D...
def create_tfs_connection(url, token): """ Creates the TFS Connection Context """ if token is None: token = os.environ.get('TFS_API_TOKEN', None) tfs_credentials = BasicAuthentication('', token) tfs_connection = VssConnection(base_url=url, creds=tfs_credentials) return tfs_connectio...
def create_tfs_project_analysis_client(url, token=None): """ Create a project_analysis_client.py client for a Team Foundation Server Enterprise connection instance. This is helpful for understanding project languages, but currently blank for all our test conditions. If token is not provided, will attem...
def create_tfs_core_client(url, token=None): """ Create a core_client.py client for a Team Foundation Server Enterprise connection instance If token is not provided, will attempt to use the TFS_API_TOKEN environment variable if present. """ if token is None: token = os.environ.get('TFS_...
def create_tfs_git_client(url, token=None): """ Creates a TFS Git Client to pull Git repo info """ if token is None: token = os.environ.get('TFS_API_TOKEN', None) tfs_connection = create_tfs_connection(url, token) tfs_git_client = tfs_connection.get_client('vsts.git.v4_1.git_client.GitC...
def create_tfs_tfvc_client(url, token=None): """ Creates a TFS TFVC Client to pull TFVC repo info """ if token is None: token = os.environ.get('TFS_API_TOKEN', None) tfs_connection = create_tfs_connection(url, token) tfs_tfvc_client = tfs_connection.get_client('vsts.tfvc.v4_1.tfvc_clien...
def get_all_projects(url, token, top=HARD_CODED_TOP): """ Returns a list of all projects with their collection info from the server. Currently limited functionality to only return the first 1000 projects. #TODO refactor to add multiple calls to api to retrieve all projects if more exist beyond top. """ ...
def get_git_repos(url, token, collection, project): """ Returns a list of all git repos for the supplied project within the supplied collection """ git_client = create_tfs_git_client('{url}/{collection_name}'.format(url=url, collection_name=collection.name), token) logger.debug('Retrieving Git Repos...
def get_tfvc_repos(url, token, collection, project): """ Returns a list of all tfvc branches for the supplied project within the supplied collection """ branch_list = [] tfvc_client = create_tfs_tfvc_client('{url}/{collection_name}'.format(url=url, collection_name=collection.name), token) logge...
def get_year_commits(self, username='', password='', organization='llnl', force=True): """ Does setup such as login, printing API info, and waiting for GitHub to build the commit statistics. Then gets the last year of commits and prints them to file. """ date = str(dateti...
def repos(self, building_stats=False): """ Retrieves the last year of commits for the organization and stores them in weeks (UNIX time) associated with number of commits that week. """ print 'Getting repos.' for repo in self.org_retrieved.iter_repos(): for act...
def calc_total_commits(self, starting_commits=0): """ Uses the weekly commits and traverses back through the last year, each week subtracting the weekly commits and storing them. It needs an initial starting commits number, which should be taken from the most up to date number fr...
def write_to_file(self): """ Writes the weeks with associated commits to file. """ with open('../github_stats_output/last_year_commits.csv', 'w+') as output: output.write('date,organization,repos,members,teams,' + 'unique_contributors,total_contributors,forks,...
def configure(backends, raise_errors=False): """Instantiate and configures backends. :arg list-of-dicts backends: the backend configuration as a list of dicts where each dict specifies a separate backend. Each backend dict consists of two things: 1. ``class`` with a value that is eith...
def get_metrics(thing, extra=''): """Return MetricsInterface instance with specified name. The name is used as the prefix for all keys generated with this :py:class:`markus.main.MetricsInterface`. The :py:class:`markus.main.MetricsInterface` is not tied to metrics backends. The list of active back...
def timing(self, stat, value, tags=None): """Record a timing value. Record the length of time of something to be added to a set of values from which a statistical distribution is derived. Depending on the backend, you might end up with count, average, median, 95% and max for a ...
def timer(self, stat, tags=None): """Contextmanager for easily computing timings. :arg string stat: A period delimited alphanumeric key. :arg list-of-strings tags: Each string in the tag consists of a key and a value separated by a colon. Tags can make it easier to break down ...
def timer_decorator(self, stat, tags=None): """Timer decorator for easily computing timings. :arg string stat: A period delimited alphanumeric key. :arg list-of-strings tags: Each string in the tag consists of a key and a value separated by a colon. Tags can make it easier to break...
def incr(self, stat, value=1, tags=None): """Increment a counter.""" self.client.incr(stat=stat, count=value)
def timing(self, stat, value, tags=None): """Measure a timing for statistical distribution.""" self.client.timing(stat=stat, delta=value)
def incr(self, stat, value=1, tags=None): """Increment a counter.""" self.client.increment(metric=stat, value=value, tags=tags)
def gauge(self, stat, value, tags=None): """Set a gauge.""" self.client.gauge(metric=stat, value=value, tags=tags)
def timing(self, stat, value, tags=None): """Measure a timing for statistical distribution.""" self.client.timing(metric=stat, value=value, tags=tags)
def histogram(self, stat, value, tags=None): """Measure a value for statistical distribution.""" self.client.histogram(metric=stat, value=value, tags=tags)
def generate_tag(key, value=None): """Generate a tag for use with the tag backends. The key and value (if there is one) are sanitized according to the following rules: 1. after the first character, all characters must be alphanumeric, underscore, minus, period, or slash--invalid characters are ...
def incr(self, stat, value=1, tags=None): """Increment a counter.""" self._log('incr', stat, value, tags)
def gauge(self, stat, value, tags=None): """Set a gauge.""" self._log('gauge', stat, value, tags)
def timing(self, stat, value, tags=None): """Report a timing.""" self._log('timing', stat, value, tags)
def histogram(self, stat, value, tags=None): """Report a histogram.""" self._log('histogram', stat, value, tags)
def rollup(self): """Roll up stats and log them.""" now = time.time() if now < self.next_rollup: return self.next_rollup = now + self.flush_interval for key, values in sorted(self.incr_stats.items()): self.logger.info( '%s INCR %s: count:...
def incr(self, stat, value=1, tags=None): """Increment a counter.""" self.rollup() # FIXME(willkg): what to do with tags? self.incr_stats.setdefault(stat, []).append(value)
def gauge(self, stat, value, tags=None): """Set a gauge.""" self.rollup() # FIXME(willkg): what to do with tags? self.gauge_stats.setdefault(stat, []).append(value)
def timing(self, stat, value, tags=None): """Measure a timing for statistical distribution. Note: timing is a special case of histogram. """ self.histogram(stat, value, tags)
def histogram(self, stat, value, tags=None): """Measure a value for statistical distribution.""" self.rollup() # FIXME(willkg): what to do with tags? self.histogram_stats.setdefault(stat, []).append(value)
def order_enum(field, members): """ Make an annotation value that can be used to sort by an enum field. ``field`` The name of an EnumChoiceField. ``members`` An iterable of Enum members in the order to sort by. Use like: .. code-block:: python desired_order = [MyEnum...
def from_db_value(self, value, expression, connection, context): """ Convert a string from the database into an Enum value """ if value is None: return value return self.enum[value]
def to_python(self, value): """ Convert a string from a form into an Enum value. """ if value is None: return value if isinstance(value, self.enum): return value return self.enum[value]
def get_prep_value(self, value): """ Convert an Enum value into a string for the database """ if value is None: return None if isinstance(value, self.enum): return value.name raise ValueError("Unknown value {value:r} of type {cls}".format( ...
def count_id(w0): """ 0 -> no terms idd 1 -> most term idd are shared in root morphem 2 -> most term idd are shared in flexing morphem 3 -> most term idd are shared root <-> flexing (crossed) :param w0: :param w1: :return: """ def f(w1): count = [set(w0.root).intersectio...
def count_relations(w0): """ 0 -> no terms idd 1 -> most term idd are shared in root morphem 2 -> most term idd are shared in flexing morphem 3 -> most term idd are shared root <-> flexing (crossed) :param w0: :param w1: :return: """ root_w0_relations = set(chain.from_iterable(r...
def t_parse(self, s): """Parses the input string, and returns a reference to the created AST's root""" # self.root = None # self.path = s with self.lock: try: return self.parser.parse(s, lexer=self.lexer, debug=False) except CannotParse as e: ...
def p_path(self, p): """path : additive_path""" if len(p[1].children) == 1: p[0] = p[1].children[0] else: p[0] = p[1]
def p_path_sum(self, p): """ path_sum : ctx_path | path_sum PLUS ctx_path""" if len(p) == 2: p[0] = [p[1]] else: p[0] = p[1] + [p[3]]
def p_ctx_path(self, p): """ ctx_path : ctx_coords""" if len(p[1]) == 1: p[0] = p[1][0] else: p[0] = ContextPath(p[1])
def p_ctx_coords(self, p): """ ctx_coords : multiplicative_path | ctx_coords COLON multiplicative_path""" if len(p) == 2: p[0] = [p[1]] else: p[0] = p[1] + [p[3]]
def p_product(self, p): """ product : additive_path_p | coordinate | product additive_path_p | product coordinate""" if len(p) == 2: p[0] = [p[1]] else: p[0] = p[1] + [p[2]]
def p_coordinate(self, p): """ coordinate : COORD_KIND | COORD_KIND COORD_INDEX""" if len(p) == 2: p[0] = Coordinate(p[1]) else: p[0] = Coordinate(p[1], int(p[2]))
def diff(version0, version1): """ Display the terms added and removed between two versions :param version0: :param version1: :return: """ version0.load() version1.load() deleted = set(version0.terms) - set(version1.terms) added = set(version1.terms) - set(version0.terms) pr...
def load(self): """ Download the dictionary version and cache the retrieved file. :return: None """ if self.loaded: return file_name = "%s.json" % str(self) file = os.path.join(VERSIONS_FOLDER, file_name) if not os.path.isfile(file): ...
def _rotate_sc_additive(s): """ s.-S:.U:.-'l.-S:.O:.-'n.-S:.U:.-',+M:.-'M:.-'n.-S:.U:.-', => n.-S:.U:.-'s.-S:.U:.-'l.-S:.O:.-',+n.-S:.U:.-‘M:.-‘M:.-‘,""" if isinstance(s, AdditiveScript): return AdditiveScript([_rotate_sc(_s) for _s in s]) else: return _rotate_sc(s)
def _promote_and_split(s): """ E:F:.O:M:.t.- => E:.-F:.O:M:.-t.-‘ E:F:.M:M:.l.- => E:.-F:.M:M:.-l.-‘ """ subst, attr, mode = s subst0, subst1, _mode = subst assert isinstance(_mode, NullScript) return m(m(m(subst0)) ,m(m(subst1), attr) ,m(mode))
def _transfer_substance(s): """ E:O:.-M:O:.-t.o.-' => E:.-O:.M:O:.-t.o.-‘ """ subst, attr, mode = s attr0, attr1, attr2 = attr assert isinstance(attr1, NullScript) and isinstance(attr2, NullScript) subst, subst1, subst2 = subst assert isinstance(subst1, NullScript) and isinstance(subst2,...
def _add_mode_t(s): """ O:O:.O:O:.- => O:O:.O:O:.t.- """ subst, attr, mode = s assert isinstance(mode, NullScript) return m(subst, attr, script('t.'))
def _insert_f_additive(s): """i.B:.-+u.M:.-O:.-' => i.f.B:.-+u.f.M:.-O:.-'""" subst, attr, mode = s assert isinstance(mode, NullScript) if isinstance(subst, AdditiveScript): subst = AdditiveScript([_insert_attr_f(_s) for _s in subst]) else: subst = _insert_attr_f(subst) return ...
def _fix_typo(s): """M:.-O:.-'M:.-wa.e.-'t.x.-s.y.-', => M:.-O:.-'M:.-wa.e.-'t.-x.-s.y.-',""" subst, attr, mode = s return m(subst, attr, script("t.-x.-s.y.-'"))
def translate_script(to_translate): """ translate the root paradigms in key in argument, with the function in value :param to_translate: :return: """ version = DictionaryVersion(latest_dictionary_version()) version.load() to_remove = [] to_add = { 'terms': [], 'roots'...
def translate_mouvements_et_milieux(s): """i.f.B:.-+u.f.M:.-O:.-' -> i.B:.-+u.M:.-O:.-'""" subst, attr, mode = s assert isinstance(mode, NullScript) if isinstance(subst, AdditiveScript): subst = AdditiveScript([_remove_attr_f(_s) for _s in subst]) else: subst = _remove_attr_f(subst)...
def translate_competence_en_curr_data(s): """M:.-O:.-'M:.-wa.e.-'t.-x.-s.y.-', => t.-x.-s.y.-' wa.e.-', M:M:.-',O:.-',_""" subst, attr, mode = s attr_s, attr_a, attr_m = attr assert isinstance(attr_m, NullScript) subst_s, subst_a, subst_m = subst assert isinstance(subst_m, NullScript) firs...
def translate_noetic(s): """M:.O:.-O:.O:.-B:.T:.n.-' => s.M:O:.O:O:.-""" subst, attr, mode = s return m(script('s.'), m(subst.children[0].children[0], subst.children[1].children[0]), m(attr.children[0].children[0], attr.children[1].children[0]))
def translate_tisse_intl_col(s): """O:M:.-O:M:.-we.h.-' => O:M:.-'O:M:.-'s.o.-k.o.-',""" subst, attr, mode = s return m(m(subst), m(attr), script("s.o.-k.o.-'"))
def translate_formes_visuelles(s): """s.u.-'O:M:.-'O:.-',+s.u.-'M:O:.-O:.-'M:.-', => b.-S:.U:.-'O:M:.-'O:.-', + b.-S:.U:.-'M:O:.-O:.-'M:.-',""" def set_bSU_subst(s): subst, attr, mode = s return m(script("b.-S:.U:.-'"), attr, mode) if isinstance(s, AdditiveScript): return AdditiveS...
def translate_ecosystem_intl_col(s): """O:.M:.- => s.o.-k.o.-'M:O:.-',""" subst, attr, mode = s return m(script("s.o.-k.o.-'"), m(m(m(attr.children[0], subst.children[0]))))
def translate_ecosystem_intl_col_tern(s): """O:.M:.-M:.-' => s.o.-k.o.-‘M:O:.-‘,M:.-',_""" subst, attr, mode = s return m(translate_ecosystem_intl_col(subst), m(m(attr)))
def parse(self, s): """Parses the input string, and returns a reference to the created AST's root""" with self.lock: try: return self.parser.parse(s, lexer=self.lexer) except InvalidIEMLObjectArgument as e: raise CannotParse(s, str(e)) ...
def p_literal_list(self, p): """literal_list : literal_list LITERAL | LITERAL""" if len(p) == 3: p[0] = p[1] + [p[2][1:-1]] else: p[0] = [p[1][1:-1]]
def p_word(self, p): """word : TERM | LBRACKET TERM RBRACKET | LBRACKET TERM RBRACKET literal_list""" try: term = self._get_term(p[1 if len(p) == 2 else 2]) except TermNotFoundInDictionary as e: raise CannotParse(self._ieml, str(e)) ...
def p_proposition_sum(self, p): """word_sum : word_sum PLUS word | word clauses_sum : clauses_sum PLUS clause | clause superclauses_sum : superclauses_sum PLUS superclause | superclause""" # closed_proposition_list : cl...
def p_topic(self, p): """topic : LBRACKET morpheme RBRACKET | LBRACKET morpheme RBRACKET literal_list | LBRACKET morpheme TIMES morpheme RBRACKET | LBRACKET morpheme TIMES morpheme RBRACKET literal_list""" if len(p) == 4: p[0] = Topic(root=tup...
def p_fact(self, p): """fact : LBRACKET clauses_sum RBRACKET | LBRACKET clauses_sum RBRACKET literal_list""" if len(p) == 4: p[0] = Fact(p[2]) else: p[0] = Fact(p[2], literals=p[4])
def p_theory(self, p): """theory : LBRACKET superclauses_sum RBRACKET | LBRACKET superclauses_sum RBRACKET literal_list""" if len(p) == 4: p[0] = Theory(p[2]) else: p[0] = Theory(p[2], literals=p[4])
def p_closed_proposition_list(self, p): """ closed_proposition_list : closed_proposition_list SLASH SLASH closed_proposition | closed_proposition""" if len(p) == 2: p[0] = [p[1]] else: p[0] = p[1] + [p[4]]
def pack_factorisation(facto_list): """ :param facto_list: list of parser or tuple of factorisation :return: """ _sum = [] for f in facto_list: if isinstance(f, Script): _sum.append(f) else: # tuple of factorisation _sum.append(MultiplicativeSc...
def connexity(self): """ A boolean matrix, m[i, j] == True if there is a relation term(i) -> term(j) :return: a np.matrix (len(dictionary), len(dictionary)) of boolean """ return np.matrix(sum(self.relations.values()).todense(), dtype=bool)
def _resolve_path(obj, path): """path is a mul of coord or a coord""" if obj.__class__ not in path.context.accept: result = set() for ctx in path.context.accept: result |= {e for u in obj[ctx] for e in _resolve_path(u, path)} return result if isinstance(obj, Text): ...
def _resolve_ctx(rules): """ Resolve the context of the rules (the type of this element), and building the ieml element. :param rules: :return: """ if not rules: raise ResolveError("Missing node definition.") # if rules == [(None, e)] --> e if len(rules) == 1 and rules[0][0] is ...
def project_usls_on_dictionary(usls, allowed_terms=None): """`usls` is an iterable of usl. return a mapping term -> usl list """ cells_to_usls = defaultdict(set) tables = set() for u in usls: for t in u.objects(Term): for c in t.singular_sequences: # This i...
def project_usl_with_data(usls_data, metric=None): """ usls_data: usl => data[] :param usls_data: :return: """ projection = project_usls_on_dictionary(usls_data) all_terms = set(c for u in usls_data for t in u.objects(Term) for c in t.singular_sequences) if metric is None: metri...
def p_script_lvl_0(self, p): """ script_lvl_0 : PRIMITIVE LAYER0_MARK | REMARKABLE_ADDITION LAYER0_MARK""" if p[1] == 'E': p[0] = NullScript(layer=0) elif p[1] in REMARKABLE_ADDITION: p[0] = AdditiveScript(character=p[1]) else: ...
def p_sum_lvl_0(self, p): """ sum_lvl_0 : script_lvl_0 | script_lvl_0 PLUS sum_lvl_0""" if len(p) == 4: p[3].append(p[1]) p[0] = p[3] else: p[0] = [p[1]]
def p_script_lvl_1(self, p): """ script_lvl_1 : additive_script_lvl_0 LAYER1_MARK | additive_script_lvl_0 additive_script_lvl_0 LAYER1_MARK | additive_script_lvl_0 additive_script_lvl_0 additive_script_lvl_0 LAYER1_MARK | REMARKABLE_MULTIPL...
def p_sum_lvl_1(self, p): """ sum_lvl_1 : script_lvl_1 | script_lvl_1 PLUS sum_lvl_1""" if len(p) == 4: p[3].append(p[1]) p[0] = p[3] else: p[0] = [p[1]]
def square_order_matrix(usl_list): """ Compute the ordering of a list of usls from each usl and return the matrix m s.t. for each u in usl_list at index i, [usl_list[j] for j in m[i, :]] is the list sorted by proximity from u. of the result :param usl_list: a list of usls :return: a (len(us...
def accept_script(self, script): """ True when the term is a subset of this term tables. If the parent of this term is already a TableSet,return always false (only one main tableset) :param term: :return: """ if isinstance(self.parent, TableSet): retur...
def _build_pools(self): """ Slow method, retrieve all the terms from the database. :return: """ if self.level >= Topic: # words self.topics_pool = set(self.topic() for i in range(self.pool_size)) if self.level >= Fact: # sentences ...
def mean(self): """Returns the mean value.""" if self.counter.value > 0: return self.sum.value / self.counter.value return 0.0
def variance(self): """Returns variance""" if self.counter.value <= 1: return 0.0 return self.var.value[1] / (self.counter.value - 1)
def mark(self, value=1): """Record an event with the meter. By default it will record one event. :param value: number of event to record """ self.counter += value self.m1_rate.update(value) self.m5_rate.update(value) self.m15_rate.update(value)
def mean_rate(self): """ Returns the mean rate of the events since the start of the process. """ if self.counter.value == 0: return 0.0 else: elapsed = time() - self.start_time return self.counter.value / elapsed
def mark(self, value=1): """Record an event with the derive. :param value: counter value to record """ last = self.last.get_and_set(value) if last <= value: value = value - last super(Derive, self).mark(value)
def mmap(func, iterable): """Wrapper to make map() behave the same on Py2 and Py3.""" if sys.version_info[0] > 2: return [i for i in map(func, iterable)] else: return map(func, iterable)
def send_metric(self, name, metric): """Send metric and its snapshot.""" config = SERIALIZER_CONFIG[class_name(metric)] mmap( self._buffered_send_metric, self.serialize_metric( metric, name, config['keys'], ...
def serialize_metric(self, metric, m_name, keys, m_type): """Serialize and send available measures of a metric.""" return [ self.format_metric_string(m_name, getattr(metric, key), m_type) for key in keys ]
def format_metric_string(self, name, value, m_type): """Compose a statsd compatible string for a metric's measurement.""" # NOTE(romcheg): This serialized metric template is based on # statsd's documentation. template = '{name}:{value}|{m_type}\n' if self.prefix:...
def _buffered_send_metric(self, metric_str): """Add a metric to the buffer.""" self.batch_count += 1 self.batch_buffer += metric_str # NOTE(romcheg): Send metrics if the number of metrics in the buffer # has reached the threshold for sending. if self.bat...