Search is not available for this dataset
text stringlengths 75 104k |
|---|
def parse(self, scope):
""" Parse Node
args:
scope (Scope): Scope object
raises:
SyntaxError
returns:
str
"""
assert (len(self.tokens) == 3)
expr = self.process(self.tokens, scope)
A, O, B = [
e[0] if isinsta... |
def with_units(self, val, ua, ub):
"""Return value with unit.
args:
val (mixed): result
ua (str): 1st unit
ub (str): 2nd unit
raises:
SyntaxError
returns:
str
"""
if not val:
return str(val)
i... |
def operate(self, vala, valb, oper):
"""Perform operation
args:
vala (mixed): 1st value
valb (mixed): 2nd value
oper (str): operation
returns:
mixed
"""
operation = {
'+': operator.add,
'-': operator.sub,
... |
def parse(self, filename=None, file=None, debuglevel=0):
""" Parse file.
kwargs:
filename (str): File to parse
debuglevel (int): Parser debuglevel
"""
self.scope.push()
if not file:
# We use a path.
file = filename
else:
... |
def post_parse(self):
""" Post parse cycle. nodejs version allows calls to mixins
not yet defined or known to the parser. We defer all calls
to mixins until after first cycle when all names are known.
"""
if self.result:
out = []
for pu in self.result:
... |
def p_unit_list(self, p):
""" unit_list : unit_list unit
| unit
"""
if isinstance(p[1], list):
if len(p) >= 3:
if isinstance(p[2], list):
p[1].extend(p[2])
else:
... |
def p_statement_aux(self, p):
""" statement : css_charset t_ws css_string t_semicolon
| css_namespace t_ws css_string t_semicolon
"""
p[0] = Statement(list(p)[1:], p.lineno(1))
p[0].parse(None) |
def p_statement_namespace(self, p):
""" statement : css_namespace t_ws word css_string t_semicolon
"""
p[0] = Statement(list(p)[1:], p.lineno(1))
p[0].parse(None) |
def p_statement_import(self, p):
""" import_statement : css_import t_ws string t_semicolon
| css_import t_ws css_string t_semicolon
| css_import t_ws css_string media_query_list t_semicolon
| css_import t_ws f... |
def p_block(self, p):
""" block_decl : block_open declaration_list brace_close
"""
p[0] = Block(list(p)[1:-1], p.lineno(3))
self.scope.pop()
self.scope.add_block(p[0]) |
def p_block_replace(self, p):
""" block_decl : identifier t_semicolon
"""
m = p[1].parse(None)
block = self.scope.blocks(m.raw())
if block:
p[0] = block.copy_inner(self.scope)
else:
# fallback to mixin. Allow calls to mixins without p... |
def p_block_open(self, p):
""" block_open : identifier brace_open
"""
try:
p[1].parse(self.scope)
except SyntaxError:
pass
p[0] = p[1]
self.scope.current = p[1] |
def p_font_face_open(self, p):
""" block_open : css_font_face t_ws brace_open
"""
p[0] = Identifier([p[1], p[2]]).parse(self.scope) |
def p_mixin(self, p):
""" mixin_decl : open_mixin declaration_list brace_close
"""
self.scope.add_mixin(Mixin(list(p)[1:], p.lineno(3)).parse(self.scope))
self.scope.pop()
p[0] = None |
def p_open_mixin(self, p):
""" open_mixin : identifier t_popen mixin_args_list t_pclose brace_open
| identifier t_popen mixin_args_list t_pclose mixin_guard brace_open
"""
p[1].parse(self.scope)
self.scope.current = p[1]
p[0] =... |
def p_mixin_guard_cond_list_aux(self, p):
""" mixin_guard_cond_list : mixin_guard_cond_list t_comma mixin_guard_cond
| mixin_guard_cond_list less_and mixin_guard_cond
"""
p[1].append(p[2])
p[1].append(p[3])
p[0] = p[1] |
def p_call_mixin(self, p):
""" call_mixin : identifier t_popen mixin_args_list t_pclose t_semicolon
"""
p[1].parse(None)
p[0] = Deferred(p[1], p[3], p.lineno(4)) |
def p_declaration_list(self, p):
""" declaration_list : declaration_list declaration
| declaration
| empty
"""
if len(p) > 2:
p[1].extend(p[2])
p[0] = p[1] |
def p_variable_decl(self, p):
""" variable_decl : variable t_colon style_list t_semicolon
"""
p[0] = Variable(list(p)[1:-1], p.lineno(4))
p[0].parse(self.scope) |
def p_property_decl(self, p):
""" property_decl : prop_open style_list t_semicolon
| prop_open style_list css_important t_semicolon
| prop_open empty t_semicolon
"""
l = len(p)
p[0] = Property(list(p)[1:-1]... |
def p_identifier_list_aux(self, p):
""" identifier_list : identifier_list t_comma identifier_group
"""
p[1].extend([p[2]])
p[1].extend(p[3])
p[0] = p[1] |
def p_identifier_group_op(self, p):
""" identifier_group : identifier_group child_selector ident_parts
| identifier_group '+' ident_parts
| identifier_group general_sibling_selector ident_parts
... |
def p_ident_parts_aux(self, p):
""" ident_parts : ident_parts ident_part
| ident_parts filter_group
"""
if isinstance(p[2], list):
p[1].extend(p[2])
else:
p[1].append(p[2])
p[0] = p[1] |
def p_ident_parts(self, p):
""" ident_parts : ident_part
| selector
| filter_group
"""
if not isinstance(p[1], list):
p[1] = [p[1]]
p[0] = p[1] |
def p_media_query_value(self, p):
""" media_query_value : number
| variable
| word
| color
| expression
"""
if utility.is_vari... |
def p_color(self, p):
""" color : css_color
| css_color t_ws
"""
try:
p[0] = Color().fmt(p[1])
if len(p) > 2:
p[0] = [p[0], p[2]]
except ValueError:
self.handle_error('Illegal color ... |
def p_error(self, t):
""" Internal error handler
args:
t (Lex token): Error token
"""
if t:
error_msg = "E: %s line: %d, Syntax Error, token: `%s`, `%s`" % \
(self.target, t.lineno, t.type, t.value)
self.register.register(error_ms... |
def handle_error(self, e, line, t='E'):
""" Custom error handler
args:
e (Mixed): Exception or str
line (int): line number
t(str): Error type
"""
self.register.register("%s: line: %d: %s\n" % (t, line, e)) |
def parse(self, scope):
"""Parse node
args:
scope (Scope): current scope
raises:
SyntaxError
returns:
parsed
"""
if not self.parsed:
self.parsed = ''.join(self.process(self.tokens, scope))
return self.parsed |
def NextPage(gh):
"""
Checks if a GitHub call returned multiple pages of data.
:param gh: GitHub() instance
:rtype: int
:return: number of next page or 0 if no next page
"""
header = dict(gh.getheaders())
if 'Link' in header:
parts = header['Link'].split(',')
for part in... |
def fetch_github_token(self):
"""
Fetch GitHub token. First try to use variable provided
by --token option, otherwise try to fetch it from git config
and last CHANGELOG_GITHUB_TOKEN env variable.
:returns: Nothing
"""
if not self.options.token:
try:
... |
def get_all_tags(self):
"""
Fetch all tags for repository from Github.
:return: tags in repository
:rtype: list
"""
verbose = self.options.verbose
gh = self.github
user = self.options.user
repo = self.options.project
if verbose:
... |
def fetch_closed_issues_and_pr(self):
"""
This method fetches all closed issues and separate them to
pull requests and pure issues (pull request is kind of issue
in term of GitHub).
:rtype: list, list
:return: issues, pull-requests
"""
verbose = self.opt... |
def fetch_closed_pull_requests(self):
"""
Fetch all pull requests. We need them to detect "merged_at" parameter
:rtype: list
:return: all pull requests
"""
pull_requests = []
verbose = self.options.verbose
gh = self.github
user = self.options.use... |
def fetch_repo_creation_date(self):
"""
Get the creation date of the repository from GitHub.
:rtype: str, str
:return: special tag name, creation date as ISO date string
"""
gh = self.github
user = self.options.user
repo = self.options.project
rc,... |
def fetch_events_async(self, issues, tag_name):
"""
Fetch events for all issues and add them to self.events
:param list issues: all issues
:param str tag_name: name of the tag to fetch events for
:returns: Nothing
"""
if not issues:
return issues
... |
def fetch_date_of_tag(self, tag):
"""
Fetch time for tag from repository.
:param dict tag: dictionary with tag information
:rtype: str
:return: time of specified tag as ISO date string
"""
if self.options.verbose > 1:
print("\tFetching date for tag {... |
def fetch_commit(self, event):
"""
Fetch commit data for specified event.
:param dict event: dictionary with event information
:rtype: dict
:return: dictionary with commit data
"""
gh = self.github
user = self.options.user
repo = self.options.pro... |
def run(self):
"""
The entry point of this script to generate change log
'ChangelogGeneratorError' Is thrown when one
of the specified tags was not found in list of tags.
"""
if not self.options.project or not self.options.user:
print("Project and/or user miss... |
def parse_heading(heading):
"""
Parse a single heading and return a Hash
The following heading structures are currently valid:
- ## [v1.0.2](https://github.com/zanui/chef-thumbor/tree/v1.0.1) (2015-03-24)
- ## [v1.0.2](https://github.com/zanui/chef-thumbor/tree/v1.0.1)
- ## v1.0.2 (2015-03-24)
... |
def parse(data):
"""
Parse the given ChangeLog data into a list of Hashes.
@param [String] data File data from the ChangeLog.md
@return [Array<Hash>] Parsed data, e.g. [{ 'version' => ..., 'url' => ..., 'date' => ..., 'content' => ...}, ...]
"""
sections = re.compile("^## .+$", re.MULTILINE).s... |
def _signal_handler_map(self):
""" Create the signal handler map
create a dictionary with signal:handler mapping based on
self.signal_map
:return: dict
"""
result = {}
for signum, handler in self.signal_map.items():
result[signum] = self._get_signal_... |
def open(self):
""" Daemonize this process
Do everything that is needed to become a Unix daemon.
:return: None
:raise: DaemonError
"""
if self.is_open:
return
try:
os.chdir(self.working_directory)
if self.chroot_directory:
... |
def user_and_project_from_git(self, options, arg0=None, arg1=None):
""" Detects user and project from git. """
user, project = self.user_project_from_option(options, arg0, arg1)
if user and project:
return user, project
try:
remote = subprocess.check_output(
... |
def user_project_from_option(options, arg0, arg1):
"""
Try to find user and project name from git remote output
@param [String] output of git remote command
@return [Array] user and project
"""
site = options.github_site
if arg0 and not arg1:
# this ... |
def user_project_from_remote(remote):
"""
Try to find user and project name from git remote output
@param [String] output of git remote command
@return [Array] user and project
"""
# try to find repo in format:
# origin git@github.com:skywinder/Github-Changelog-... |
def timestring_to_datetime(timestring):
"""
Convert an ISO formated date and time string to a datetime object.
:param str timestring: String with date and time in ISO format.
:rtype: datetime
:return: datetime object
"""
with warnings.catch_warnings():
warnings.filterwarnings("ignor... |
def fetch_events_for_issues_and_pr(self):
"""
Fetch event for issues and pull requests
@return [Array] array of fetched issues
"""
# Async fetching events:
self.fetcher.fetch_events_async(self.issues, "issues")
self.fetcher.fetch_events_async(self.pull_requests,... |
def fetch_tags_dates(self):
""" Async fetching of all tags dates. """
if self.options.verbose:
print(
"Fetching dates for {} tags...".format(len(self.filtered_tags))
)
def worker(tag):
self.get_time_of_tag(tag)
# Async fetching tags:... |
def detect_actual_closed_dates(self, issues, kind):
"""
Find correct closed dates, if issues was closed by commits.
:param list issues: issues to check
:param str kind: either "issues" or "pull requests"
:rtype: list
:return: issues with updated closed dates
"""
... |
def find_closed_date_by_commit(self, issue):
"""
Fill "actual_date" parameter of specified issue by closed date of
the commit, if it was closed by commit.
:param dict issue: issue to edit
"""
if not issue.get('events'):
return
# if it's PR -> then fi... |
def set_date_from_event(self, event, issue):
"""
Set closed date from this issue.
:param dict event: event data
:param dict issue: issue data
"""
if not event.get('commit_id', None):
issue['actual_date'] = timestring_to_datetime(issue['closed_at'])
... |
def encapsulate_string(raw_string):
"""
Encapsulate characters to make markdown look as expected.
:param str raw_string: string to encapsulate
:rtype: str
:return: encapsulated input string
"""
raw_string.replace('\\', '\\\\')
enc_string = re.sub("([<>*_... |
def compound_changelog(self):
"""
Main function to start change log generation
:rtype: str
:return: Generated change log file
"""
self.fetch_and_filter_tags()
tags_sorted = self.sort_tags_by_date(self.filtered_tags)
self.filtered_tags = tags_sorted
... |
def generate_sub_section(self, issues, prefix):
"""
Generate formated list of issues for changelog.
:param list issues: Issues to put in sub-section.
:param str prefix: Title of sub-section.
:rtype: str
:return: Generated ready-to-add sub-section.
"""
lo... |
def generate_header(self, newer_tag_name, newer_tag_link,
newer_tag_time,
older_tag_link, project_url):
"""
Generate a header for a tag section with specific parameters.
:param str newer_tag_name: Name (title) of newer tag.
:param str newe... |
def generate_log_between_tags(self, older_tag, newer_tag):
"""
Generate log between 2 specified tags.
:param dict older_tag: All issues before this tag's date will be
excluded. May be special value, if new tag is
the first tag. (Mean... |
def filter_issues_for_tags(self, newer_tag, older_tag):
"""
Apply all filters to issues and pull requests.
:param dict older_tag: All issues before this tag's date will be
excluded. May be special value, if new tag is
the first tag. ... |
def generate_log_for_all_tags(self):
"""
The full cycle of generation for whole project.
:rtype: str
:return: The complete change log for released tags.
"""
if self.options.verbose:
print("Generating log...")
self.issues2 = copy.deepcopy(self.issues)... |
def generate_unreleased_section(self):
"""
Generate log for unreleased closed issues.
:rtype: str
:return: Generated ready-to-add unreleased section.
"""
if not self.filtered_tags:
return ""
now = datetime.datetime.utcnow()
now = now.replace(t... |
def get_string_for_issue(self, issue):
"""
Parse issue and generate single line formatted issue line.
Example output:
- Add coveralls integration [\#223](https://github.com/skywinder/github-changelog-generator/pull/223) ([skywinder](https://github.com/skywinder))
- Add c... |
def issue_line_with_user(self, line, issue):
"""
If option author is enabled, a link to the profile of the author
of the pull reqest will be added to the issue line.
:param str line: String containing a markdown-formatted single issue.
:param dict issue: Fetched issue from GitHu... |
def generate_log_for_tag(self,
pull_requests,
issues,
newer_tag,
older_tag_name):
"""
Generates log for tag section with header and body.
:param list(dict) pull_requests: List of ... |
def issues_to_log(self, issues, pull_requests):
"""
Generate ready-to-paste log from list of issues and pull requests.
:param list(dict) issues: List of issues in this tag section.
:param list(dict) pull_requests: List of PR's in this tag section.
:rtype: str
:return: Ge... |
def parse_by_sections(self, issues, pull_requests):
"""
This method sort issues by types (bugs, features, etc. or
just closed issues) by labels.
:param list(dict) issues: List of issues in this tag section.
:param list(dict) pull_requests: List of PR's in this tag section.
... |
def exclude_issues_by_labels(self, issues):
"""
Delete all issues with labels from exclude-labels option.
:param list(dict) issues: All issues for tag.
:rtype: list(dict)
:return: Filtered issues.
"""
if not self.options.exclude_labels:
return copy.de... |
def filter_by_milestone(self, filtered_issues, tag_name, all_issues):
"""
:param list(dict) filtered_issues: Filtered issues.
:param str tag_name: Name (title) of tag.
:param list(dict) all_issues: All issues.
:rtype: list(dict)
:return: Filtered issues according mileston... |
def find_issues_to_add(all_issues, tag_name):
"""
Add all issues, that should be in that tag, according to milestone.
:param list(dict) all_issues: All issues.
:param str tag_name: Name (title) of tag.
:rtype: List[dict]
:return: Issues filtered by milestone.
"""... |
def remove_issues_in_milestones(self, filtered_issues):
"""
:param list(dict) filtered_issues: Filtered issues.
:rtype: list(dict)
:return: List with removed issues, that contain milestones with
same name as a tag.
"""
for issue in filtered_issues:
... |
def delete_by_time(self, issues, older_tag, newer_tag):
"""
Filter issues that belong to specified tag range.
:param list(dict) issues: Issues to filter.
:param dict older_tag: All issues before this tag's date will be
excluded. May be special value, if **... |
def include_issues_by_labels(self, all_issues):
"""
Include issues with labels, specified in self.options.include_labels.
:param list(dict) all_issues: All issues.
:rtype: list(dict)
:return: Filtered issues.
"""
included_by_labels = self.filter_by_include_label... |
def filter_wo_labels(self, all_issues):
"""
Filter all issues that don't have a label.
:rtype: list(dict)
:return: Issues without labels.
"""
issues_wo_labels = []
if not self.options.add_issues_wo_labels:
for issue in all_issues:
if ... |
def filter_by_include_labels(self, issues):
"""
Filter issues to include only issues with labels
specified in include_labels.
:param list(dict) issues: Pre-filtered issues.
:rtype: list(dict)
:return: Filtered issues.
"""
if not self.options.include_labe... |
def filter_by_labels(self, all_issues, kind):
"""
Filter issues for include/exclude labels.
:param list(dict) all_issues: All issues.
:param str kind: Either "issues" or "pull requests".
:rtype: list(dict)
:return: Filtered issues.
"""
filtered_issues = ... |
def get_filtered_pull_requests(self, pull_requests):
"""
This method fetches missing params for PR and filter them
by specified options. It include add all PR's with labels
from options.include_labels and exclude all from
options.exclude_labels.
:param list(dict) pull_re... |
def filter_merged_pull_requests(self, pull_requests):
"""
This method filter only merged PR and fetch missing required
attributes for pull requests. Using merged date is more correct
than closed date.
:param list(dict) pull_requests: Pre-filtered pull requests.
:rtype: l... |
def fetch_and_filter_tags(self):
"""
Fetch and filter tags, fetch dates and sort them in time order.
"""
self.all_tags = self.fetcher.get_all_tags()
self.filtered_tags = self.get_filtered_tags(self.all_tags)
self.fetch_tags_dates() |
def sort_tags_by_date(self, tags):
"""
Sort all tags by date.
:param list(dict) tags: All tags.
:rtype: list(dict)
:return: Sorted list of tags.
"""
if self.options.verbose:
print("Sorting tags...")
tags.sort(key=lambda x: self.get_time_of_ta... |
def get_time_of_tag(self, tag):
"""
Get date and time for tag, fetching it if not already cached.
:param dict tag: Tag to get the datetime for.
:rtype: datetime
:return: datetime for specified tag.
"""
if not tag:
raise ChangelogGeneratorError("tag i... |
def detect_link_tag_time(self, tag):
"""
Detect link, name and time for specified tag.
:param dict tag: Tag data.
:rtype: str, str, datetime
:return: Link, name and time of the tag.
"""
# if tag is nil - set current time
newer_tag_time = self.get_time_of... |
def version_of_first_item(self):
"""
Try to detect the newest tag from self.options.base, otherwise
return a special value indicating the creation of the repo.
:rtype: str
:return: Tag name to use as 'oldest' tag. May be special value,
indicating the creation of... |
def get_temp_tag_for_repo_creation(self):
"""
If not already cached, fetch the creation date of the repo, cache it
and return the special value indicating the creation of the repo.
:rtype: str
:return: value indicating the creation
"""
tag_date = self.tag_times_d... |
def get_filtered_tags(self, all_tags):
"""
Return tags after filtering tags in lists provided by
option: --between-tags & --exclude-tags
:param list(dict) all_tags: All tags.
:rtype: list(dict)
:return: Filtered tags.
"""
filtered_tags = self.filter_sinc... |
def filter_since_tag(self, all_tags):
"""
Filter tags according since_tag option.
:param list(dict) all_tags: All tags.
:rtype: list(dict)
:return: Filtered tags.
"""
tag = self.detect_since_tag()
if not tag or tag == REPO_CREATED_TAG_NAME:
r... |
def filter_due_tag(self, all_tags):
"""
Filter tags according due_tag option.
:param list(dict) all_tags: Pre-filtered tags.
:rtype: list(dict)
:return: Filtered tags.
"""
filtered_tags = []
tag = self.options.due_tag
tag_names = [t["name"] for t... |
def filter_between_tags(self, all_tags):
"""
Filter tags according between_tags option.
:param list(dict) all_tags: Pre-filtered tags.
:rtype: list(dict)
:return: Filtered tags.
"""
tag_names = [t["name"] for t in all_tags]
between_tags = []
for ... |
def filter_excluded_tags(self, all_tags):
"""
Filter tags according exclude_tags and exclude_tags_regex option.
:param list(dict) all_tags: Pre-filtered tags.
:rtype: list(dict)
:return: Filtered tags.
"""
filtered_tags = copy.deepcopy(all_tags)
if self.o... |
def apply_exclude_tags_regex(self, all_tags):
"""
Filter tags according exclude_tags_regex option.
:param list(dict) all_tags: Pre-filtered tags.
:rtype: list(dict)
:return: Filtered tags.
"""
filtered = []
for tag in all_tags:
if not re.match... |
def apply_exclude_tags(self, all_tags):
"""
Filter tags according exclude_tags option.
:param list(dict) all_tags: Pre-filtered tags.
:rtype: list(dict)
:return: Filtered tags.
"""
filtered = copy.deepcopy(all_tags)
for tag in all_tags:
if tag... |
def random_chars(n):
"""
Generate a random string from a-zA-Z0-9
:param n: length of the string
:return: the random string
"""
return ''.join(random.SystemRandom().choice(string.ascii_letters + string.digits) for _ in range(n)) |
def random_letters(n):
"""
Generate a random string from a-zA-Z
:param n: length of the string
:return: the random string
"""
return ''.join(random.SystemRandom().choice(string.ascii_letters) for _ in range(n)) |
def random_numbers(n):
"""
Generate a random string from 0-9
:param n: length of the string
:return: the random string
"""
return ''.join(random.SystemRandom().choice(string.digits) for _ in range(n)) |
def dict_search(d, k, v):
"""
Search dictionary list by key and value
:param d: dictionary list
:param k: key
:param v: value
:return: the index of the first dictionary in the array with the specific key / value
"""
for i in range(len(d)):
if d[i][k] == v:
return i
... |
def dict_merge(a, b, k):
"""
Merge two dictionary lists
:param a: original list
:param b: alternative list, element will replace the one in original list with same key
:param k: key
:return: the merged list
"""
c = a.copy()
for j in range(len(b)):
flag = False
for i i... |
def dict_sort(d, k):
"""
Sort a dictionary list by key
:param d: dictionary list
:param k: key
:return: sorted dictionary list
"""
return sorted(d.copy(), key=lambda i: i[k]) |
def dict_top(d, k, n, reverse=False):
"""
Return top n of a dictionary list sorted by key
:param d: dictionary list
:param k: key
:param n: top n
:param reverse: whether the value should be reversed
:return: top n of the sorted dictionary list
"""
h = list()
for i in range(len(d)... |
def dict_flatten(d):
"""
Replace nested dict keys to underscore-connected keys
:param d: the dictionary
:return: flattened dictionary
"""
if type(d) != dict:
return d
else:
dd = dict()
for key, value in d.items():
if type(value) == dict:
fo... |
def dict_format_type(d, source, formatter, include_list=True):
"""
Replace the values of a dict with certain type to other values
:param d: the dictionary
:param source: the source type, e.g., int
:param formatter: the formatter method, e.g., return the string format of an int
:param include_lis... |
def dict_remove_key(d, k):
"""
Recursively remove a key from a dict
:param d: the dictionary
:param k: key which should be removed
:return: formatted dictionary
"""
dd = dict()
for key, value in d.items():
if not key == k:
if isinstance(value, dict):
d... |
def dict_remove_value(d, v):
"""
Recursively remove keys with a certain value from a dict
:param d: the dictionary
:param v: value which should be removed
:return: formatted dictionary
"""
dd = dict()
for key, value in d.items():
if not value == v:
if isinstance(value... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.