_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q269000
Git.parse_git_log_from_file
test
def parse_git_log_from_file(filepath): """Parse a Git log file. The method parses the Git log file and returns an iterator of dictionaries. Each one of this, contains a commit. :param filepath: path to the log file :returns: a generator of parsed commits :raises Parse...
python
{ "resource": "" }
q269001
GitCommand._pre_init
test
def _pre_init(self): """Initialize repositories directory path""" if self.parsed_args.git_log: git_path = self.parsed_args.git_log elif not self.parsed_args.git_path: base_path = os.path.expanduser('~/.perceval/repositories/') processed_uri = self.parsed_args...
python
{ "resource": "" }
q269002
GitCommand.setup_cmd_parser
test
def setup_cmd_parser(cls): """Returns the Git argument parser.""" parser = BackendCommandArgumentParser(cls.BACKEND.CATEGORIES, from_date=True, to_date=True) # Optional arguments group = parser....
python
{ "resource": "" }
q269003
GitParser.parse
test
def parse(self): """Parse the Git log stream.""" for line in self.stream: line = line.rstrip('\n') parsed = False self.nline += 1 while not parsed: parsed = self.handlers[self.state](line) if self.state == self.COMMIT and...
python
{ "resource": "" }
q269004
GitRepository.clone
test
def clone(cls, uri, dirpath): """Clone a Git repository. Make a bare copy of the repository stored in `uri` into `dirpath`. The repository would be either local or remote. :param uri: URI of the repository :param dirtpath: directory where the repository will be cloned ...
python
{ "resource": "" }
q269005
GitRepository.count_objects
test
def count_objects(self): """Count the objects of a repository. The method returns the total number of objects (packed and unpacked) available on the repository. :raises RepositoryError: when an error occurs counting the objects of a repository """ cmd_count ...
python
{ "resource": "" }
q269006
GitRepository.is_detached
test
def is_detached(self): """Check if the repo is in a detached state. The repository is in a detached state when HEAD is not a symbolic reference. :returns: whether the repository is detached or not :raises RepositoryError: when an error occurs checking the state of ...
python
{ "resource": "" }
q269007
GitRepository.update
test
def update(self): """Update repository from its remote. Calling this method, the repository will be synchronized with the remote repository using 'fetch' command for 'heads' refs. Any commit stored in the local copy will be removed; refs will be overwritten. :raises Rep...
python
{ "resource": "" }
q269008
GitRepository.sync
test
def sync(self): """Keep the repository in sync. This method will synchronize the repository with its 'origin', fetching newest objects and updating references. It uses low level commands which allow to keep track of which things have changed in the repository. The metho...
python
{ "resource": "" }
q269009
GitRepository.rev_list
test
def rev_list(self, branches=None): """Read the list commits from the repository The list of branches is a list of strings, with the names of the branches to fetch. If the list of branches is empty, no commit is fetched. If the list of branches is None, all commits for all branch...
python
{ "resource": "" }
q269010
GitRepository.log
test
def log(self, from_date=None, to_date=None, branches=None, encoding='utf-8'): """Read the commit log from the repository. The method returns the Git log of the repository using the following options: git log --raw --numstat --pretty=fuller --decorate=full --all --re...
python
{ "resource": "" }
q269011
GitRepository.show
test
def show(self, commits=None, encoding='utf-8'): """Show the data of a set of commits. The method returns the output of Git show command for a set of commits using the following options: git show --raw --numstat --pretty=fuller --decorate=full --parents -M -C -c [<co...
python
{ "resource": "" }
q269012
GitRepository._fetch_pack
test
def _fetch_pack(self): """Fetch changes and store them in a pack.""" def prepare_refs(refs): return [ref.hash.encode('utf-8') for ref in refs if not ref.refname.endswith('^{}')] def determine_wants(refs): remote_refs = prepare_refs(self._discover_ref...
python
{ "resource": "" }
q269013
GitRepository._read_commits_from_pack
test
def _read_commits_from_pack(self, packet_name): """Read the commits of a pack.""" filepath = 'objects/pack/pack-' + packet_name cmd_verify_pack = ['git', 'verify-pack', '-v', filepath] outs = self._exec(cmd_verify_pack, cwd=self.dirpath, env=self.gitenv) outs = outs.decode('ut...
python
{ "resource": "" }
q269014
GitRepository._update_references
test
def _update_references(self, refs): """Update references removing old ones.""" new_refs = [ref.refname for ref in refs] # Delete old references for old_ref in self._discover_refs(): if not old_ref.refname.startswith('refs/heads/'): continue if ol...
python
{ "resource": "" }
q269015
GitRepository._discover_refs
test
def _discover_refs(self, remote=False): """Get the current list of local or remote refs.""" if remote: cmd_refs = ['git', 'ls-remote', '-h', '-t', '--exit-code', 'origin'] sep = '\t' ignored_error_codes = [2] else: # Check first whether the local ...
python
{ "resource": "" }
q269016
GitRepository._update_ref
test
def _update_ref(self, ref, delete=False): """Update a reference.""" cmd = ['git', 'update-ref'] if delete: cmd.extend(['-d', ref.refname]) action = 'deleted' else: cmd.extend([ref.refname, ref.hash]) action = 'updated to %s' % ref.hash ...
python
{ "resource": "" }
q269017
GitRepository._exec_nb
test
def _exec_nb(self, cmd, cwd=None, env=None, encoding='utf-8'): """Run a command with a non blocking call. Execute `cmd` command with a non blocking call. The command will be run in the directory set by `cwd`. Enviroment variables can be set using the `env` dictionary. The output data is...
python
{ "resource": "" }
q269018
GitRepository._read_stderr
test
def _read_stderr(self, encoding='utf-8'): """Reads self.proc.stderr. Usually, this should be read in a thread, to prevent blocking the read from stdout of the stderr buffer is filled, and this function is not called becuase the program is busy in the stderr reading loop. ...
python
{ "resource": "" }
q269019
GitRepository._exec
test
def _exec(cmd, cwd=None, env=None, ignored_error_codes=None, encoding='utf-8'): """Run a command. Execute `cmd` command in the directory set by `cwd`. Environment variables can be set using the `env` dictionary. The output data is returned as encoded bytes. Comman...
python
{ "resource": "" }
q269020
Twitter.fetch
test
def fetch(self, category=CATEGORY_TWEET, since_id=None, max_id=None, geocode=None, lang=None, include_entities=True, tweets_type=TWEET_TYPE_MIXED): """Fetch the tweets from the server. This method fetches tweets from the TwitterSearch API published in the last seven days. ...
python
{ "resource": "" }
q269021
Twitter.fetch_items
test
def fetch_items(self, category, **kwargs): """Fetch the tweets :param category: the category of items to fetch :param kwargs: backend arguments :returns: a generator of items """ since_id = kwargs['since_id'] max_id = kwargs['max_id'] geocode = kwargs['g...
python
{ "resource": "" }
q269022
TwitterClient.tweets
test
def tweets(self, query, since_id=None, max_id=None, geocode=None, lang=None, include_entities=True, result_type=TWEET_TYPE_MIXED): """Fetch tweets for a given query between since_id and max_id. :param query: query to fetch tweets :param since_id: if not null, it returns results w...
python
{ "resource": "" }
q269023
TwitterCommand.setup_cmd_parser
test
def setup_cmd_parser(cls): """Returns the Twitter argument parser.""" parser = BackendCommandArgumentParser(cls.BACKEND.CATEGORIES, token_auth=True, archive=True) # Backend token is required act...
python
{ "resource": "" }
q269024
GoogleHits.fetch
test
def fetch(self, category=CATEGORY_HITS): """Fetch data from Google API. The method retrieves a list of hits for some given keywords using the Google API. :param category: the category of items to fetch :returns: a generator of data """ kwargs = {} items...
python
{ "resource": "" }
q269025
GoogleHits.fetch_items
test
def fetch_items(self, category, **kwargs): """Fetch Google hit items :param category: the category of items to fetch :param kwargs: backend arguments :returns: a generator of items """ logger.info("Fetching data for '%s'", self.keywords) hits_raw = self.client....
python
{ "resource": "" }
q269026
GoogleHits.__parse_hits
test
def __parse_hits(self, hit_raw): """Parse the hits returned by the Google Search API""" # Create the soup and get the desired div bs_result = bs4.BeautifulSoup(hit_raw, 'html.parser') hit_string = bs_result.find("div", id="resultStats").text # Remove commas or dots hit_...
python
{ "resource": "" }
q269027
GoogleHitsClient.hits
test
def hits(self, keywords): """Fetch information about a list of keywords.""" if len(keywords) == 1: query_str = keywords[0] else: query_str = ' '.join([k for k in keywords]) logger.info("Fetching hits for '%s'", query_str) params = {'q': query_str} ...
python
{ "resource": "" }
q269028
GitHub.metadata_updated_on
test
def metadata_updated_on(item): """Extracts the update time from a GitHub item. The timestamp used is extracted from 'updated_at' field. This date is converted to UNIX timestamp format. As GitHub dates are in UTC the conversion is straightforward. :param item: item generated by ...
python
{ "resource": "" }
q269029
GitHub.metadata_category
test
def metadata_category(item): """Extracts the category from a GitHub item. This backend generates two types of item which are 'issue' and 'pull_request'. """ if "base" in item: category = CATEGORY_PULL_REQUEST elif "forks_count" in item: category ...
python
{ "resource": "" }
q269030
GitHub.__fetch_pull_requests
test
def __fetch_pull_requests(self, from_date, to_date): """Fetch the pull requests""" raw_pulls = self.client.pulls(from_date=from_date) for raw_pull in raw_pulls: pull = json.loads(raw_pull) if str_to_datetime(pull['updated_at']) > to_date: return ...
python
{ "resource": "" }
q269031
GitHub.__fetch_repo_info
test
def __fetch_repo_info(self): """Get repo info about stars, watchers and forks""" raw_repo = self.client.repo() repo = json.loads(raw_repo) fetched_on = datetime_utcnow() repo['fetched_on'] = fetched_on.timestamp() yield repo
python
{ "resource": "" }
q269032
GitHub.__get_issue_reactions
test
def __get_issue_reactions(self, issue_number, total_count): """Get issue reactions""" reactions = [] if total_count == 0: return reactions group_reactions = self.client.issue_reactions(issue_number) for raw_reactions in group_reactions: for reaction i...
python
{ "resource": "" }
q269033
GitHub.__get_issue_comment_reactions
test
def __get_issue_comment_reactions(self, comment_id, total_count): """Get reactions on issue comments""" reactions = [] if total_count == 0: return reactions group_reactions = self.client.issue_comment_reactions(comment_id) for raw_reactions in group_reactions: ...
python
{ "resource": "" }
q269034
GitHub.__get_issue_assignees
test
def __get_issue_assignees(self, raw_assignees): """Get issue assignees""" assignees = [] for ra in raw_assignees: assignees.append(self.__get_user(ra['login'])) return assignees
python
{ "resource": "" }
q269035
GitHub.__get_pull_requested_reviewers
test
def __get_pull_requested_reviewers(self, pr_number): """Get pull request requested reviewers""" requested_reviewers = [] group_requested_reviewers = self.client.pull_requested_reviewers(pr_number) for raw_requested_reviewers in group_requested_reviewers: group_requested_rev...
python
{ "resource": "" }
q269036
GitHub.__get_pull_commits
test
def __get_pull_commits(self, pr_number): """Get pull request commit hashes""" hashes = [] group_pull_commits = self.client.pull_commits(pr_number) for raw_pull_commits in group_pull_commits: for commit in json.loads(raw_pull_commits): commit_hash = commit['...
python
{ "resource": "" }
q269037
GitHub.__get_pull_review_comment_reactions
test
def __get_pull_review_comment_reactions(self, comment_id, total_count): """Get pull review comment reactions""" reactions = [] if total_count == 0: return reactions group_reactions = self.client.pull_review_comment_reactions(comment_id) for raw_reactions in group_...
python
{ "resource": "" }
q269038
GitHub.__get_user
test
def __get_user(self, login): """Get user and org data for the login""" user = {} if not login: return user user_raw = self.client.user(login) user = json.loads(user_raw) user_orgs_raw = \ self.client.user_orgs(login) user['organizations'...
python
{ "resource": "" }
q269039
GitHubClient.issue_reactions
test
def issue_reactions(self, issue_number): """Get reactions of an issue""" payload = { 'per_page': PER_PAGE, 'direction': 'asc', 'sort': 'updated' } path = urijoin("issues", str(issue_number), "reactions") return self.fetch_items(path, payload)
python
{ "resource": "" }
q269040
GitHubClient.issues
test
def issues(self, from_date=None): """Fetch the issues from the repository. The method retrieves, from a GitHub repository, the issues updated since the given date. :param from_date: obtain issues updated since this date :returns: a generator of issues """ paylo...
python
{ "resource": "" }
q269041
GitHubClient.pulls
test
def pulls(self, from_date=None): """Fetch the pull requests from the repository. The method retrieves, from a GitHub repository, the pull requests updated since the given date. :param from_date: obtain pull requests updated since this date :returns: a generator of pull request...
python
{ "resource": "" }
q269042
GitHubClient.repo
test
def repo(self): """Get repository data""" path = urijoin(self.base_url, 'repos', self.owner, self.repository) r = self.fetch(path) repo = r.text return repo
python
{ "resource": "" }
q269043
GitHubClient.pull_requested_reviewers
test
def pull_requested_reviewers(self, pr_number): """Get pull requested reviewers""" requested_reviewers_url = urijoin("pulls", str(pr_number), "requested_reviewers") return self.fetch_items(requested_reviewers_url, {})
python
{ "resource": "" }
q269044
GitHubClient.pull_commits
test
def pull_commits(self, pr_number): """Get pull request commits""" payload = { 'per_page': PER_PAGE, } commit_url = urijoin("pulls", str(pr_number), "commits") return self.fetch_items(commit_url, payload)
python
{ "resource": "" }
q269045
GitHubClient.pull_review_comment_reactions
test
def pull_review_comment_reactions(self, comment_id): """Get reactions of a review comment""" payload = { 'per_page': PER_PAGE, 'direction': 'asc', 'sort': 'updated' } path = urijoin("pulls", "comments", str(comment_id), "reactions") return se...
python
{ "resource": "" }
q269046
GitHubClient.user
test
def user(self, login): """Get the user information and update the user cache""" user = None if login in self._users: return self._users[login] url_user = urijoin(self.base_url, 'users', login) logging.info("Getting info for %s" % (url_user)) r = self.fetch...
python
{ "resource": "" }
q269047
GitHubClient.user_orgs
test
def user_orgs(self, login): """Get the user public organizations""" if login in self._users_orgs: return self._users_orgs[login] url = urijoin(self.base_url, 'users', login, 'orgs') try: r = self.fetch(url) orgs = r.text except requests.except...
python
{ "resource": "" }
q269048
GitHubClient._get_token_rate_limit
test
def _get_token_rate_limit(self, token): """Return token's remaining API points""" rate_url = urijoin(self.base_url, "rate_limit") self.session.headers.update({'Authorization': 'token ' + token}) remaining = 0 try: headers = super().fetch(rate_url).headers ...
python
{ "resource": "" }
q269049
GitHubClient._get_tokens_rate_limits
test
def _get_tokens_rate_limits(self): """Return array of all tokens remaining API points""" remainings = [0] * self.n_tokens # Turn off archiving when checking rates, because that would cause # archive key conflict (the same URLs giving different responses) arch = self.archive ...
python
{ "resource": "" }
q269050
GitHubClient._choose_best_api_token
test
def _choose_best_api_token(self): """Check all API tokens defined and choose one with most remaining API points""" # Return if no tokens given if self.n_tokens == 0: return # If multiple tokens given, choose best token_idx = 0 if self.n_tokens > 1: ...
python
{ "resource": "" }
q269051
GitHubClient._need_check_tokens
test
def _need_check_tokens(self): """Check if we need to switch GitHub API tokens""" if self.n_tokens <= 1 or self.rate_limit is None: return False elif self.last_rate_limit_checked is None: self.last_rate_limit_checked = self.rate_limit return True # If...
python
{ "resource": "" }
q269052
GitHubClient._update_current_rate_limit
test
def _update_current_rate_limit(self): """Update rate limits data for the current token""" url = urijoin(self.base_url, "rate_limit") try: # Turn off archiving when checking rates, because that would cause # archive key conflict (the same URLs giving different responses) ...
python
{ "resource": "" }
q269053
Archive.init_metadata
test
def init_metadata(self, origin, backend_name, backend_version, category, backend_params): """Init metadata information. Metatada is composed by basic information needed to identify where archived data came from and how it can be retrieved and built into Perceval it...
python
{ "resource": "" }
q269054
Archive.store
test
def store(self, uri, payload, headers, data): """Store a raw item in this archive. The method will store `data` content in this archive. The unique identifier for that item will be generated using the rest of the parameters. :param uri: request URI :param payload: reque...
python
{ "resource": "" }
q269055
Archive.retrieve
test
def retrieve(self, uri, payload, headers): """Retrieve a raw item from the archive. The method will return the `data` content corresponding to the hascode derived from the given parameters. :param uri: request URI :param payload: request payload :param headers: request ...
python
{ "resource": "" }
q269056
Archive.create
test
def create(cls, archive_path): """Create a brand new archive. Call this method to create a new and empty archive. It will initialize the storage file in the path defined by `archive_path`. :param archive_path: absolute path where the archive file will be created :raises Arch...
python
{ "resource": "" }
q269057
Archive.make_hashcode
test
def make_hashcode(uri, payload, headers): """Generate a SHA1 based on the given arguments. Hashcodes created by this method will used as unique identifiers for the raw items or resources stored by this archive. :param uri: URI to the resource :param payload: payload of the requ...
python
{ "resource": "" }
q269058
Archive._verify_archive
test
def _verify_archive(self): """Check whether the archive is valid or not. This method will check if tables were created and if they contain valid data. """ nentries = self._count_table_rows(self.ARCHIVE_TABLE) nmetadata = self._count_table_rows(self.METADATA_TABLE) ...
python
{ "resource": "" }
q269059
Archive._load_metadata
test
def _load_metadata(self): """Load metadata from the archive file""" logger.debug("Loading metadata infomation of archive %s", self.archive_path) cursor = self._db.cursor() select_stmt = "SELECT origin, backend_name, backend_version, " \ "category, backend_params, ...
python
{ "resource": "" }
q269060
Archive._count_table_rows
test
def _count_table_rows(self, table_name): """Fetch the number of rows in a table""" cursor = self._db.cursor() select_stmt = "SELECT COUNT(*) FROM " + table_name try: cursor.execute(select_stmt) row = cursor.fetchone() except sqlite3.DatabaseError as e: ...
python
{ "resource": "" }
q269061
ArchiveManager.create_archive
test
def create_archive(self): """Create a new archive. The method creates in the filesystem a brand new archive with a random SHA1 as its name. The first byte of the hashcode will be the name of the subdirectory; the remaining bytes, the archive name. :returns: a new `Archi...
python
{ "resource": "" }
q269062
ArchiveManager.remove_archive
test
def remove_archive(self, archive_path): """Remove an archive. This method deletes from the filesystem the archive stored in `archive_path`. :param archive_path: path to the archive :raises ArchiveManangerError: when an error occurs removing the archive """ ...
python
{ "resource": "" }
q269063
ArchiveManager.search
test
def search(self, origin, backend_name, category, archived_after): """Search archives. Get the archives which store data based on the given parameters. These parameters define which the origin was (`origin`), how data was fetched (`backend_name`) and data type ('category'). Only ...
python
{ "resource": "" }
q269064
ArchiveManager._search_archives
test
def _search_archives(self, origin, backend_name, category, archived_after): """Search archives using filters.""" for archive_path in self._search_files(): try: archive = Archive(archive_path) except ArchiveError: continue match = arch...
python
{ "resource": "" }
q269065
ArchiveManager._search_files
test
def _search_files(self): """Retrieve the file paths stored under the base path.""" for root, _, files in os.walk(self.dirpath): for filename in files: location = os.path.join(root, filename) yield location
python
{ "resource": "" }
q269066
check_compressed_file_type
test
def check_compressed_file_type(filepath): """Check if filename is a compressed file supported by the tool. This function uses magic numbers (first four bytes) to determine the type of the file. Supported types are 'gz' and 'bz2'. When the filetype is not supported, the function returns `None`. :pa...
python
{ "resource": "" }
q269067
months_range
test
def months_range(from_date, to_date): """Generate a months range. Generator of months starting on `from_date` util `to_date`. Each returned item is a tuple of two datatime objects like in (month, month+1). Thus, the result will follow the sequence: ((fd, fd+1), (fd+1, fd+2), ..., (td-2, td-1), ...
python
{ "resource": "" }
q269068
message_to_dict
test
def message_to_dict(msg): """Convert an email message into a dictionary. This function transforms an `email.message.Message` object into a dictionary. Headers are stored as key:value pairs while the body of the message is stored inside `body` key. Body may have two other keys inside, 'plain', for p...
python
{ "resource": "" }
q269069
remove_invalid_xml_chars
test
def remove_invalid_xml_chars(raw_xml): """Remove control and invalid characters from an xml stream. Looks for invalid characters and subtitutes them with whitespaces. This solution is based on these two posts: Olemis Lang's reponse on StackOverflow (http://stackoverflow.com/questions/1707890) and l...
python
{ "resource": "" }
q269070
xml_to_dict
test
def xml_to_dict(raw_xml): """Convert a XML stream into a dictionary. This function transforms a xml stream into a dictionary. The attributes are stored as single elements while child nodes are stored into lists. The text node is stored using the special key '__text__'. This code is based on Wi...
python
{ "resource": "" }
q269071
Redmine.parse_issues
test
def parse_issues(raw_json): """Parse a Redmine issues JSON stream. The method parses a JSON stream and returns a list iterator. Each item is a dictionary that contains the issue parsed data. :param raw_json: JSON string to parse :returns: a generator of parsed issues "...
python
{ "resource": "" }
q269072
RedmineClient.issues
test
def issues(self, from_date=DEFAULT_DATETIME, offset=None, max_issues=MAX_ISSUES): """Get the information of a list of issues. :param from_date: retrieve issues that where updated from that date; dates are converted to UTC :param offset: starting position for the searc...
python
{ "resource": "" }
q269073
RedmineClient.issue
test
def issue(self, issue_id): """Get the information of the given issue. :param issue_id: issue identifier """ resource = urijoin(self.RISSUES, str(issue_id) + self.CJSON) params = { self.PINCLUDE: ','.join([self.CATTACHMENTS, self.CCHANGESETS, ...
python
{ "resource": "" }
q269074
RedmineClient.user
test
def user(self, user_id): """Get the information of the given user. :param user_id: user identifier """ resource = urijoin(self.RUSERS, str(user_id) + self.CJSON) params = {} response = self._call(resource, params) return response
python
{ "resource": "" }
q269075
RedmineClient._call
test
def _call(self, resource, params): """Call to get a resource. :param method: resource to get :param params: dict with the HTTP parameters needed to get the given resource """ url = self.URL % {'base': self.base_url, 'resource': resource} if self.api_token: ...
python
{ "resource": "" }
q269076
DockerHub.fetch
test
def fetch(self, category=CATEGORY_DOCKERHUB_DATA): """Fetch data from a Docker Hub repository. The method retrieves, from a repository stored in Docker Hub, its data which includes number of pulls, stars, description, among other data. :param category: the category of items to ...
python
{ "resource": "" }
q269077
DockerHub.fetch_items
test
def fetch_items(self, category, **kwargs): """Fetch the Dockher Hub items :param category: the category of items to fetch :param kwargs: backend arguments :returns: a generator of items """ logger.info("Fetching data from '%s' repository of '%s' owner", ...
python
{ "resource": "" }
q269078
DockerHubClient.repository
test
def repository(self, owner, repository): """Fetch information about a repository.""" url = urijoin(self.base_url, self.RREPOSITORY, owner, repository) logger.debug("DockerHub client requests: %s", url) response = self.fetch(url) return response.text
python
{ "resource": "" }
q269079
map_custom_field
test
def map_custom_field(custom_fields, fields): """Add extra information for custom fields. :param custom_fields: set of custom fields with the extra information :param fields: fields of the issue where to add the extra information :returns: an set of items with the extra information mapped """ d...
python
{ "resource": "" }
q269080
filter_custom_fields
test
def filter_custom_fields(fields): """Filter custom fields from a given set of fields. :param fields: set of fields :returns: an object with the filtered custom fields """ custom_fields = {} sorted_fields = [field for field in fields if field['custom'] is True] for custom_field in sorted...
python
{ "resource": "" }
q269081
Jira.parse_issues
test
def parse_issues(raw_page): """Parse a JIRA API raw response. The method parses the API response retrieving the issues from the received items :param items: items from where to parse the issues :returns: a generator of issues """ raw_issues = json.loads(raw_pag...
python
{ "resource": "" }
q269082
JiraClient.get_items
test
def get_items(self, from_date, url, expand_fields=True): """Retrieve all the items from a given date. :param url: endpoint API url :param from_date: obtain items updated since this date :param expand_fields: if True, it includes the expand fields in the payload """ start...
python
{ "resource": "" }
q269083
JiraClient.get_issues
test
def get_issues(self, from_date): """Retrieve all the issues from a given date. :param from_date: obtain issues updated since this date """ url = urijoin(self.base_url, self.RESOURCE, self.VERSION_API, 'search') issues = self.get_items(from_date, url) return issues
python
{ "resource": "" }
q269084
JiraClient.get_comments
test
def get_comments(self, issue_id): """Retrieve all the comments of a given issue. :param issue_id: ID of the issue """ url = urijoin(self.base_url, self.RESOURCE, self.VERSION_API, self.ISSUE, issue_id, self.COMMENT) comments = self.get_items(DEFAULT_DATETIME, url, expand_fields=...
python
{ "resource": "" }
q269085
JiraClient.get_fields
test
def get_fields(self): """Retrieve all the fields available.""" url = urijoin(self.base_url, self.RESOURCE, self.VERSION_API, 'field') req = self.fetch(url) return req.text
python
{ "resource": "" }
q269086
Jenkins.fetch
test
def fetch(self, category=CATEGORY_BUILD): """Fetch the builds from the url. The method retrieves, from a Jenkins url, the builds updated since the given date. :param category: the category of items to fetch :returns: a generator of builds """ kwargs = {} ...
python
{ "resource": "" }
q269087
JenkinsClient.get_jobs
test
def get_jobs(self): """ Retrieve all jobs""" url_jenkins = urijoin(self.base_url, "api", "json") response = self.fetch(url_jenkins) return response.text
python
{ "resource": "" }
q269088
JenkinsClient.get_builds
test
def get_builds(self, job_name): """ Retrieve all builds from a job""" if self.blacklist_jobs and job_name in self.blacklist_jobs: logger.warning("Not getting blacklisted job: %s", job_name) return payload = {'depth': self.detail_depth} url_build = urijoin(self.b...
python
{ "resource": "" }
q269089
StackExchange.parse_questions
test
def parse_questions(raw_page): """Parse a StackExchange API raw response. The method parses the API response retrieving the questions from the received items :param items: items from where to parse the questions :returns: a generator of questions """ raw_questi...
python
{ "resource": "" }
q269090
StackExchangeClient.get_questions
test
def get_questions(self, from_date): """Retrieve all the questions from a given date. :param from_date: obtain questions updated since this date """ page = 1 url = urijoin(self.base_url, self.VERSION_API, "questions") req = self.fetch(url, payload=self.__build_payload(p...
python
{ "resource": "" }
q269091
StackExchangeCommand.setup_cmd_parser
test
def setup_cmd_parser(cls): """Returns the StackExchange argument parser.""" parser = BackendCommandArgumentParser(cls.BACKEND.CATEGORIES, from_date=True, token_auth=True, ...
python
{ "resource": "" }
q269092
MediaWiki.fetch_items
test
def fetch_items(self, category, **kwargs): """Fetch the pages :param category: the category of items to fetch :param kwargs: backend arguments :returns: a generator of items """ from_date = kwargs['from_date'] reviews_api = kwargs['reviews_api'] mediawi...
python
{ "resource": "" }
q269093
MediaWiki.__get_max_date
test
def __get_max_date(self, reviews): """"Get the max date in unixtime format from reviews.""" max_ts = 0 for review in reviews: ts = str_to_datetime(review['timestamp']) ts = datetime_to_utc(ts) if ts.timestamp() > max_ts: max_ts = ts.timestamp()...
python
{ "resource": "" }
q269094
MediaWiki.__fetch_1_27
test
def __fetch_1_27(self, from_date=None): """Fetch the pages from the backend url for MediaWiki >=1.27 The method retrieves, from a MediaWiki url, the wiki pages. :returns: a generator of pages """ logger.info("Looking for pages at url '%s'", self.url) npages = ...
python
{ "resource": "" }
q269095
MediaWikiClient.get_pages
test
def get_pages(self, namespace, apcontinue=''): """Retrieve all pages from a namespace starting from apcontinue.""" params = { "action": "query", "list": "allpages", "aplimit": self.limit, "apnamespace": namespace, "format": "json" } ...
python
{ "resource": "" }
q269096
MediaWikiClient.get_recent_pages
test
def get_recent_pages(self, namespaces, rccontinue=''): """Retrieve recent pages from all namespaces starting from rccontinue.""" namespaces.sort() params = { "action": "query", "list": "recentchanges", "rclimit": self.limit, "rcnamespace": "|".joi...
python
{ "resource": "" }
q269097
Telegram.fetch
test
def fetch(self, category=CATEGORY_MESSAGE, offset=DEFAULT_OFFSET, chats=None): """Fetch the messages the bot can read from the server. The method retrieves, from the Telegram server, the messages sent with an offset equal or greater than the given. A list of chats, groups and channels ...
python
{ "resource": "" }
q269098
Telegram.parse_messages
test
def parse_messages(raw_json): """Parse a Telegram JSON messages list. The method parses the JSON stream and returns an iterator of dictionaries. Each one of this, contains a Telegram message. :param raw_json: JSON string to parse :returns: a generator of parsed messages ...
python
{ "resource": "" }
q269099
Telegram._filter_message_by_chats
test
def _filter_message_by_chats(self, message, chats): """Check if a message can be filtered based in a list of chats. This method returns `True` when the message was sent to a chat of the given list. It also returns `True` when chats is `None`. :param message: Telegram message :p...
python
{ "resource": "" }