code string | signature string | docstring string | loss_without_docstring float64 | loss_with_docstring float64 | factor float64 |
|---|---|---|---|---|---|
global _time_caches
if delete_all:
_time_caches = []
_parser = { "default": CodeParser() }
else:
# normally just kill the expired entries, not all
for tc in _time_caches:
# check time_cache for expired entries
for key, (t, value) in list(tc.items... | def clear_caches(delete_all=False) | Fortpy caches many things, that should be completed after each completion
finishes.
:param delete_all: Deletes also the cache that is normally not deleted,
like parser cache, which is important for faster parsing. | 6.550414 | 6.832145 | 0.958764 |
def _temp(key_func):
dct = {}
_time_caches.append(dct)
def wrapper(optional_callable, *args, **kwargs):
key = key_func(*args, **kwargs)
value = None
if key in dct:
expiry, value = dct[key]
if expiry > time.time():
... | def time_cache(time_add_setting) | This decorator works as follows: Call it with a setting and after that
use the function with a callable that returns the key.
But: This function is only called if the key is not available. After a
certain amount of time (`time_add_setting`) the cache is invalid. | 3.19215 | 3.099858 | 1.029773 |
index = user_pos[0] - 1
lines = source.splitlines() or ['']
if source and source[-1] == '\n':
lines.append('')
before_cursor = lines[index][:user_pos[1]]
other_lines = lines[stmt.start_pos[0]:index]
whole = '\n'.join(other_lines + [before_cursor])
before_bracket = re.match(r'.*... | def cache_call_signatures(source, user_pos, stmt) | This function calculates the cache key. | 4.350356 | 4.407582 | 0.987016 |
return Node((cos(-angle)*distance+self.pos[0],
sin(-angle)*distance+self.pos[1])) | def make_new_node(self, distance, angle) | Make a new node from an existing one.
This method creates a new node with a distance and angle given.
The position of the new node is calculated with:
x2 = cos(-angle)*distance+x1
y2 = sin(-angle)*distance+y1
Args:
distance (float): The distance of the original node... | 5.099728 | 5.199578 | 0.980796 |
return atan2(self.pos[0]-node.pos[0], self.pos[1]-node.pos[1]) - pi / 2 | def get_node_angle(self, node) | Get the angle beetween 2 nodes relative to the horizont.
Args:
node (object): The other node.
Returns:
rad: The angle | 3.383022 | 4.774115 | 0.708618 |
delta = (node.pos[0]-self.pos[0], node.pos[1]-self.pos[1])
return sqrt(delta[0]**2+delta[1]**2) | def get_distance(self, node) | Get the distance beetween 2 nodes
Args:
node (object): The other node. | 2.500609 | 2.934997 | 0.851997 |
self.pos = (self.pos[0]+delta[0], self.pos[1]+delta[1]) | def move(self, delta) | Move the node.
Args:
delta (tupel): A tupel, holding the adjustment of the position. | 2.452091 | 2.631623 | 0.931779 |
oparams = []
pmembers = {}
xassigns = map(lambda x: x.lower().strip(), executable.external_assignments())
def add_offense(pname, member):
if pname not in oparams:
oparams.append(pname)
if pname not in pmembers:
pmembers[pname] = [member]
els... | def _exec_check_pointers(executable) | Checks the specified executable for the pointer condition that not
all members of the derived type have had their values set.
Returns (list of offending members, parameter name). | 5.326989 | 4.924562 | 1.081718 |
result = []
for mname, member in utype.members.items():
if ("pointer" in member.modifiers and member.D > 0 and
(member.default is None or "null" not in member.default)):
result.append(member)
return result | def _type_check_pointers(utype) | Checks the user-derived type for non-nullified pointer array declarations
in its base definition.
Returns (list of offending members). | 5.74347 | 5.221456 | 1.099975 |
from fnmatch import fnmatch
from fortpy.msg import std, set_verbosity, info
set_verbosity(0)
W1 = " {} '{}' does not set the value of members '{}' in parameter '{}'."
W2 = " Type '{}' does not nullify members '{}' on creation."
offenders = {}
for (modname, module) in parser.module... | def check_pointers(parser, codedir=None, mfilter=None, recursive=False) | Checks the modules in the specified code parser to see if they
have common, but subtle, pointer bugs in:
1. subroutines with a parameter of intent(out) and user-derived type
must* set *all* members of that parameter or they will have an
*undefined* status.
2. pointer-type arrays that are not nu... | 4.561379 | 4.294622 | 1.062114 |
url = 'https://app.hydrawise.com/api/v1/statusschedule.php'
payload = {
'api_key': token,
'hours': 168}
get_response = requests.get(url, params=payload, timeout=REQUESTS_TIMEOUT)
if get_response.status_code == 200 and \
'error_msg' not in get_response.json():
retu... | def status_schedule(token) | Returns the json string from the Hydrawise server after calling
statusschedule.php.
:param token: The users API token.
:type token: string
:returns: The response from the controller. If there was an error returns
None.
:rtype: string or None | 3.76887 | 2.852258 | 1.321364 |
# Actions must be one from this list.
action_list = [
'run', # Run a zone for an amount of time.
'runall', # Run all zones for an amount of time.
'stop', # Stop a zone.
'stopall', # stop all zones.
'suspend', # Suspend a zone for an amount of t... | def set_zones(token, action, relay=None, time=None) | Controls the zone relays to turn sprinklers on and off.
:param token: The users API token.
:type token: string
:param action: The action to perform. Available actions are: run, runall,
stop, stopall, suspend, and suspendall.
:type action: string
:param relay: The zone to take act... | 2.991931 | 2.761173 | 1.083572 |
# We loop over the objects here rather than use queryset.update() for
# two reasons:
#
# 1. No one should ever be updating zillions of Topics or Questions, so
# performance is not an issue.
# 2. To be tidy, we want to log what the user has done.
#
for obj in queryset:
... | def update_status(modeladmin, request, queryset, status) | The workhorse function for the admin action functions that follow. | 4.051833 | 4.119797 | 0.983503 |
for depkey, depval in xinst.dependencies.items():
if depval.target is not None:
if depval.target.name in result:
if xinst not in result[depval.target.name]:
result[depval.target.name].append(xinst)
else:
result[depval.target.na... | def _exec_callers(xinst, result) | Adds the dependency calls from the specified executable instance
to the results dictionary. | 2.605925 | 2.378097 | 1.095802 |
if modname in result:
#We have already processed this module.
return
module = parser.get(modname)
mresult = {}
if module is not None:
for xname, xinst in module.executables():
_exec_callers(xinst, mresult)
result[modname] = mresult
f... | def _module_callers(parser, modname, result) | Adds any calls to executables contained in the specified module. | 4.340837 | 4.05553 | 1.07035 |
#Since we don't keep track of the specific logic in the executables
#it is possible that we could get a infinite recursion of executables
#that keep calling each other.
if executable in branch:
return
branch.append(executable)
if executable.name in calls:
for caller in ... | def _call_fan(branch, calls, executable) | Appends a list of callees to the branch for each parent
in the call list that calls this executable. | 8.093564 | 6.813313 | 1.187904 |
extra_context = {
'question_list': Question.objects.published().filter(topic__slug=slug),
}
return object_detail(request, queryset=Topic.objects.published(),
extra_context=extra_context, template_object_name='topic', slug=slug) | def topic_detail(request, slug) | A detail view of a Topic
Templates:
:template:`faq/topic_detail.html`
Context:
topic
An :model:`faq.Topic` object.
question_list
A list of all published :model:`faq.Question` objects that relate
to the given :model:`faq.Topic`. | 3.305976 | 3.591934 | 0.920389 |
url = reverse('faq-topic-detail', kwargs={'slug': topic_slug})
return _fragmentify(Question, slug, url) | def question_detail(request, topic_slug, slug) | A detail view of a Question.
Simply redirects to a detail page for the related :model:`faq.Topic`
(:view:`faq.views.topic_detail`) with the addition of a fragment
identifier that links to the given :model:`faq.Question`.
E.g. ``/faq/topic-slug/#question-slug``. | 10.939984 | 10.468925 | 1.044996 |
line = self.line
return self._element.start - self._element.module.charindex(line, 0) | def column(self) | The column where the definition occurs (starting with 0). | 20.36269 | 13.640395 | 1.492823 |
result = ""
if isinstance(self._element, ValueElement):
if self._element.kind is not None:
result = "{}({}) | {}".format(self._element.dtype, self._element.kind,
self._element.summary)
else:
result... | def description(self) | Returns the full docstring information for the element suggested
as a completion. | 5.215675 | 4.894794 | 1.065556 |
if self.context.el_type in [Function, Subroutine]:
return self.evaluator.element.parameters | def params(self) | Raises an ``AttributeError``if the definition is not callable.
Otherwise returns a list of `ValueElement` that represents the params. | 27.353983 | 20.909473 | 1.30821 |
if hasattr(self._element, "name"):
return self._element.name
else:
return str(self._element) | def name(self) | Similar to :attr:`complete`, but return the whole word, for
example::
subrout
would return `subroutine`. | 4.160604 | 5.112247 | 0.81385 |
#This is a little tricker because the docstring is housed
#inside of the module that contains the actual executable.
#These TypeExecutables are just pointers.
iexec = self._element.target
if iexec is not None:
result = "method() | " + iexec.summary
el... | def _type_description(self) | Gets the completion description for a TypeExecutable. | 24.749331 | 17.986853 | 1.375968 |
anime_info = self.parse_sidebar(character_page)
try:
character_title = filter(lambda x: 'Characters & Voice Actors' in x.text, character_page.find_all(u'h2'))
anime_info[u'characters'] = {}
anime_info[u'voice_actors'] = {}
if character_title:
character_title = character_tit... | def parse_characters(self, character_page) | Parses the DOM and returns anime character attributes in the sidebar.
:type character_page: :class:`bs4.BeautifulSoup`
:param character_page: MAL anime character page's DOM
:rtype: dict
:return: anime character attributes
:raises: :class:`.InvalidAnimeError`, :class:`.MalformedAnimePageError` | 2.417624 | 2.397393 | 1.008439 |
for i in range(len(self.docstring)):
if (self.docstring[i].doctype == doc.doctype and
self.docstring[i].pointsto == doc.pointsto):
del self.docstring[i]
break
self.docstring.append(doc) | def overwrite_docs(self, doc) | Adds the specified DocElement to the docstring list. However, if an
element with the same xml tag and pointsto value already exists, it
will be overwritten. | 3.249823 | 2.100774 | 1.546965 |
for doc in self.docstring:
if (doc.parent_name is not None and
doc.parent_name in self.groups):
doc.group = self.groups[doc.parent_name] | def unpickle_docs(self) | Sets the pointers for the docstrings that have groups. | 5.376755 | 3.332343 | 1.613506 |
if hasattr(self, "docstart") and self.docstart > 0:
return self.docstart
else:
return self.start | def absstart(self) | Returns the absolute start of the element by including docstrings
outside of the element definition if applicable. | 4.435772 | 3.435227 | 1.29126 |
if self._module is None:
root = self
while self._module is None and root is not None:
if isinstance(root, Module):
self._module = root
else:
root = root.parent
return self._module | def module(self) | Returns the module that this code element belongs to. | 2.873835 | 2.539082 | 1.13184 |
if self._summary is None:
self._summary = "No summary for element."
for doc in self.docstring:
if doc.doctype == "summary":
self._summary = doc.contents
break
#If a parameter, member or local tag has dimensions... | def summary(self) | Returns the docstring summary for the code element if it exists. | 5.923534 | 4.963114 | 1.193512 |
if self._full_name is None:
ancestors = [ self.name ]
current = self.parent
while current is not None and type(current).__name__ != "CodeParser":
ancestors.append(current.name)
current = current.parent
self._full_name = ".... | def full_name(self) | Returns the full name of this element by visiting every
non-None parent in its ancestor chain. | 3.082576 | 2.783529 | 1.107435 |
result = []
for doc in self.docstring:
if len(limiters) == 0 or doc.doctype in limiters:
result.extend(doc.children(doctype))
return result | def doc_children(self, doctype, limiters=[]) | Finds all grand-children of this element's docstrings that match
the specified doctype. If 'limiters' is specified, only docstrings
with those doctypes are searched. | 5.023022 | 2.802829 | 1.792126 |
if not self.has_docstring():
collection.append("WARNING: no docstring on code element {}".format(self.name)) | def warn(self, collection) | Checks this code element for documentation related problems. | 13.952294 | 6.617856 | 2.10828 |
mods = ["allocatable", "pointer"]
return (self.kind.lower() == other.kind.lower() and
self.dtype.lower() == other.dtype.lower() and
self.D == other.D and
all([m in other.modifiers for m in self.modifiers if m in mods])) | def matched(self, other) | Returns True if the two ValueElement instances differ only by name,
default value or some other inconsequential modifier. | 5.340296 | 4.672318 | 1.142965 |
if self.kind is not None:
return "{}({})".format(self.dtype, self.kind)
else:
return self.dtype | def strtype(self) | Returns a string representing the type and kind of this value element. | 4.564919 | 3.49174 | 1.307348 |
if index is None:
if ("allocatable" not in self.modifiers and "pointer" not in self.modifiers
and self.dtype != "logical"):
#The fortan logical has type 4 by default, whereas c_bool only has 1
return self.name
else:
... | def _get_ctypes_name(self, index=None) | Returns a formatted name for the ctypes Fortran wrapper module.
:arg index: the index of the array to return a name for. None for the new parameter,
otherwise the index for the integer variable name of that dimension. | 7.48298 | 7.64608 | 0.978669 |
if self._ctypes_parameter is None:
#Essentially, we just need to check if we are an array that doesn't have explicitly
#defined bounds. Assumed-shape arrays have to be 'pointer' or 'allocatable'. However,
#the deffered/assumed shape arrays always use ':' as the array... | def ctypes_parameter(self) | Returns the parameter list for this ValueElement adjusted for interoperability
with the ctypes module. | 6.548792 | 6.373423 | 1.027516 |
if self._direction is None:
if hasattr(self, "parameters"):
#This is actually a function that inherited from ValueElement, it is always
#intent(out) for our purposes.
self._direction = "(out)"
else:
intent = [m for ... | def direction(self) | Returns the direction of the variable if it is a parameter. Possible values
are ["": no intent, "(in)", "(out)", "(inout)"]. | 6.374031 | 4.682137 | 1.361351 |
kind = "({})".format(self.kind) if self.kind is not None else ""
cleanmods = [m for m in self.modifiers if m != "" and m != " "
and not (local and ("intent" in m or m == "optional"))
and not (not optionals and m == "optional")]
if modifiers i... | def definition(self, suffix = "", local=False, ctype=None, optionals=True,
customdim=None, modifiers=None) | Returns the fortran code string that would define this value element.
:arg suffix: an optional suffix to append to the name of the variable.
Useful for re-using definitions with new names.
:arg local: when True, the parameter definition is re-cast as a local
variable definition that... | 3.056396 | 3.068703 | 0.995989 |
if self.dimension is not None:
result = []
if "in" in self.direction:
#The only complication here is that the 'known' dimensionality could actually
#be a function like "size" that needs information about other variables.
#If we cho... | def argtypes(self) | Returns the ctypes argtypes for use with the method.argtypes assignment for
an executable loaded from a shared library. | 4.740426 | 4.723933 | 1.003491 |
if self.dtype == "logical":
return "C_BOOL"
elif self.dtype == "complex":
#We don't actually know what the precision of the complex numbers is because
#it is defined by the developer when they construct the number with CMPLX()
#We just return doub... | def ctype(self) | Returns the name of the c_type from iso_c_binding to use when declaring
the output parameter for interaction with python ctypes. | 3.523976 | 3.413308 | 1.032423 |
from re import match
if self._kind_module is not None:
#We have already done this search at some point.
return self._kind_module.name
if (self.kind is not None and "len=" not in self.kind.lower()
and not match("\d", self.kind[0])):
#Find ... | def dependency(self) | Returns the module name from the code parser that this parameter/variable
needs to compile successfully. | 10.712904 | 9.6868 | 1.105928 |
result = None
if self.is_custom:
#Look for the module that declares this variable's kind in its public list.
self.dependency()
if self._kind_module is not None:
if self.kind.lower() in self._kind_module.types:
result = self... | def customtype(self) | If this variable is a user-derivedy type, return the CustomType instance that
is its kind. | 6.704779 | 5.471316 | 1.225442 |
target = self.target
if target is not None:
return "{}.{}".format(target.name.lower(), self.name)
else:
return "{}.{}".format(self.module.name.lower(), self.name) | def external_name(self) | Returns the modulename.executable string that uniquely identifies
the executable that this dependency points to. | 3.240046 | 2.821666 | 1.148274 |
if self._target is None:
if '%' in self.name:
parts = self.name.split('%')
base = self.module.parent.type_search(parts[0], self.name, self.module)
if base is not None:
self._target = base.target
else:
... | def target(self) | Returns the executable code element that this dependency points to
if it can be found. | 3.50582 | 3.118466 | 1.124213 |
result = []
for arg in argslist:
if type(arg) == type([]):
if len(result) > 0:
result[-1] = result[-1] + "(*{})".format(len(self.clean(arg)))
elif "/" not in arg[0]:
msg.warn("argument to function call unrecogni... | def clean(self, argslist) | Cleans the argslist. | 4.802616 | 4.660644 | 1.030462 |
#All objects instances of decorable also inherit from CodeElement,
#so we should have no problem accessing the start and end attributes.
result = None
if hasattr(self, "start") and hasattr(self, "end"):
#The 8 seems arbitrary, but it is the length of type::b\n for a
... | def find_section(self, charindex) | Returns a value indicating whether the specified character index
is owned by the current object. | 8.405357 | 8.68538 | 0.967759 |
#It is understood that this executable's module is obviously required. Just
#add any additional modules from the parameters.
result = [p.dependency() for p in self.ordered_parameters]
result.extend([v.dependency() for k, v in list(self.members.items())])
for ekey, anexec... | def search_dependencies(self) | Returns a list of modules that this executable needs in order to run
properly. This includes special kind declarations for precision or derived
types, but not dependency executable calls. | 8.348575 | 6.673686 | 1.250969 |
self.parent = parent
self._unpickle_collection(self.members)
self._unpickle_collection(self.dependencies)
self._unpickle_collection(self.types)
self._unpickle_collection(self.executables)
self._unpickle_collection(self._parameters)
self.unpickle_docs() | def unpickle(self, parent) | Sets the parent pointer references for the module *and* all of its
child classes that also have pointer references. | 3.770812 | 3.527167 | 1.069077 |
for mkey in collection:
if isinstance(collection[mkey], list):
for item in collection[mkey]:
item.unpickle(self)
else:
collection[mkey].unpickle(self) | def _unpickle_collection(self, collection) | Unpickles all members of the specified dictionary. | 2.862571 | 2.633742 | 1.086884 |
section = self.find_section(self.module.charindex(linenum, 1))
if section == "body":
xparser.parse_line(statement, self, mode)
elif section == "signature":
if mode == "insert":
xparser.parse_signature(statement, self) | def rt_update(self, statement, linenum, mode, xparser) | Uses the specified line parser to parse the given line.
:arg statement: a string of lines that are part of a single statement.
:arg linenum: the line number of the first line in the list relative to
the entire module contents.
arg mode: either 'insert', 'replace' or 'delete'
:... | 6.601638 | 5.744291 | 1.149252 |
if name != self.name:
self.parent.executables[name] = self
del self.parent.executables[self.name]
self.name = name | def update_name(self, name) | Changes the name of this executable and the reference to it in the
parent module. | 3.218405 | 2.370968 | 1.357422 |
if self._is_type_target is None:
#All we need to do is search through the custom types in the parent
#module and see if any of their executables points to this method.
self._is_type_target = False
for tkey in self.module.types:
custype = s... | def is_type_target(self) | Returns the CustomType instance if this executable is an embedded
procedure in a custom type declaration; else False. | 4.331655 | 3.468672 | 1.248794 |
#Initialize the dictionary if we are the first executable to call this.
myname = "{}.{}".format(self.module.name, self.name).lower()
if checked is None:
checked = []
if myname not in checked:
matches = self._get_assignments_in(self._parameters, symbol)
... | def changed(self, symbol, checked = None) | Returns true if the specified symbol has it's value changed
by this executable or *any* of its dependencies. | 5.385076 | 5.206957 | 1.034208 |
if symbol != "":
lsymbol = symbol
for assign in self._assignments:
target = assign.split("%")[0].lower()
if target == lsymbol:
return True
else:
result = []
for assign in self._assignments:
... | def _get_assignments_in(self, filterlist, symbol = "") | Returns a list of code elements whose names are in the specified object.
:arg filterlist: the list of symbols to check agains the assignments.
:arg symbol: when specified, return true if that symbol has its value
changed via an assignment. | 3.347424 | 3.413043 | 0.980774 |
result = None
if index < len(self.paramorder):
key = self.paramorder[index]
if key in self._parameters:
result = self._parameters[key]
return result | def get_parameter(self, index) | Returns the ValueElement corresponding to the parameter
at the specified index. | 3.485294 | 3.291048 | 1.059022 |
if parameter.name.lower() not in self.paramorder:
self.paramorder.append(parameter.name.lower())
self._parameters[parameter.name.lower()] = parameter | def add_parameter(self, parameter) | Adds the specified parameter value to the list. | 3.110805 | 3.081241 | 1.009595 |
if parameter_name in self.paramorder:
index = self.paramorder.index(parameter_name)
del self.paramorder[index]
if parameter_name in self._parameters:
del self._parameters[parameter_name] | def remove_parameter(self, parameter_name) | Removes the specified parameter from the list. | 2.565153 | 2.368258 | 1.083139 |
params = ", ".join([ p.name for p in self.ordered_parameters ])
return params | def parameters_as_string(self) | Returns a comma-separated list of the parameters in the executable definition. | 7.646977 | 6.112937 | 1.25095 |
if not value in self._assignments:
self._assignments.append(value) | def add_assignment(self, value) | Adds the name of a variable/parameter whose value is changed by
this exectuable. | 4.13882 | 4.687006 | 0.883041 |
if value.name in self.dependencies:
self.dependencies[value.name.lower()].append(value)
else:
self.dependencies[value.name.lower()] = [ value ] | def add_dependency(self, value) | Adds the specified executable dependency to the list for this executable. | 2.710456 | 2.629161 | 1.030921 |
self.update_name(name)
self.modifiers = modifiers
self.dtype = dtype
self.kind = kind
self.update_dtype() | def update(self, name, modifiers, dtype, kind) | Updates the attributes for the function instance, handles name changes
in the parent module as well. | 2.801145 | 3.024331 | 0.926203 |
if self.dtype is None:
#search the members of this function for one that has the same name
#as the function. If it gets found, overwrite the dtype, kind and
#modifiers attributes so the rest of the code works.
for m in self.members:
if m =... | def update_dtype(self, resvar=None) | Updates the dtype attribute of the function. This is required because
fortran functions can have their types declared either as a modifier on
the function *or* as a member inside the function.
:arg resvar: the name of the variable declared using the result(var)
construct after the fun... | 4.981148 | 4.655107 | 1.070039 |
kind = "({}) ".format(self.kind) if self.kind is not None else ""
mods = ", ".join(self.modifiers) + " "
dtype = self.dtype if self.dtype is not None else ""
return "{}{}{}".format(dtype, kind, mods) | def returns(self) | Gets a string showing the return type and modifiers for the
function in a nice display format. | 5.017636 | 4.669057 | 1.074657 |
mods = ", ".join(self.modifiers)
return "{} SUBROUTINE {}({})".format(mods, self.name,
self.parameters_as_string()) | def signature(self) | Returns the signature definition for the subroutine. | 11.205978 | 6.989879 | 1.603172 |
self.update_name(name)
self.modifiers = modifiers | def update(self, name, modifiers) | Updates the attributes for the subroutine instance, handles name changes
in the parent module as well. | 6.287273 | 6.152574 | 1.021893 |
if self.pointsto is not None:
#It is in the format of module.executable.
xinst = self.module.parent.get_executable(self.pointsto.lower())
return xinst
else:
#The executable it points to is the same as its name.
fullname = "{}.{}".forma... | def target(self) | Returns the code element that is the actual executable that this type
executable points to. | 7.215746 | 5.521549 | 1.306834 |
possible = [m for m in self.members.values() if not m.is_custom]
#If any of the possible variables is not allocatable or pointer, it will always
#have a value and we can just use that.
sufficient = [m for m in possible if "allocatable" not in m.modifiers
an... | def fixedvar(self) | Returns the name of a member in this type that is non-custom
so that it would terminate the auto-class variable context chain. | 5.587288 | 5.065799 | 1.102943 |
for m in self.members.values():
if m.kind is not None and m.kind.lower() == self.name.lower():
return True
else:
return False | def recursive(self) | When True, this CustomType has at least one member that is of the same
type as itself. | 5.088534 | 4.129139 | 1.232347 |
if name != self.name:
self.parent.types[name] = self
del self.parent.types[self.name]
self.name = name | def update_name(self, name) | Updates the name of the custom type in this instance and its
parent reference. | 3.376176 | 2.971205 | 1.136299 |
self.parent = parent
self._unpickle_collection(self.members)
self._unpickle_collection(self.executables)
self.unpickle_docs() | def unpickle(self, parent) | Sets the parent pointer references for the type *and* all of its
child classes that also have pointer references. | 6.683558 | 6.14693 | 1.0873 |
if self.first:
return self.first.changed(name)
else:
return False | def changed(self, name) | Returns true if the parameter with the specified name has its value changed by
the *first* module procedure in the interface.
:arg name: the name of the parameter to check changed status for. | 5.251892 | 7.382727 | 0.711376 |
result = []
for target in self.targets:
if target is not None:
result.append(target.get_parameter(index))
return result | def get_parameter(self, index) | Gets the list of parameters at the specified index in the calling argument
list for each of the module procedures in the interface.
:arg index: the 0-based index of the parameter in the argument list. | 3.723699 | 5.332151 | 0.698348 |
#The docstrings for the interface are compiled from the separate docstrings
#of the module procedures it is an interface for. We choose the first of these
#procedures by convention and copy its docstrings over.
#Just use the very first embedded method that isn't None and has a d... | def find_docstring(self) | Sets the docstring of this interface using the docstrings of its embedded
module procedures that it is an interface for. | 12.917528 | 8.32077 | 1.552444 |
#Interfaces are tricky because we can have an arbitrary number of embedded procedures
#that each have different calling interfaces and return types. We are trying to
#summarize that information in a single interface. Interfaces can't mix executable
#types; they are either all s... | def describe(self) | Returns a home-grown description that includes a summary of the calling interface
for all the module procedures embedded in this interface. | 5.423106 | 5.021554 | 1.079966 |
if self._first is None:
for target in self.targets:
if target is not None:
self._first = target
break
else:
self._first = False
return self._first | def first(self) | Returns the first module procedure embedded in the interface that has a valid
instance of a CodeElement. | 3.311728 | 3.185071 | 1.039766 |
if self._targets is None:
self._targets = {}
for key in self.procedures:
element = self.module.parent.get_executable(key)
if element is not None:
self._targets[key] = element
else:
self._targ... | def targets(self) | Provides an ordered list of CodeElement instances for each of the embedded
module procedures in the generic interface. | 4.472215 | 3.285406 | 1.361237 |
result = [self.module.name]
#First we look at the explicit use references from this module and all
#its dependencies until the chain terminates.
stack = self.needs
while len(stack) > 0:
module = stack.pop()
if module in result:
con... | def search_dependencies(self) | Returns a list of other modules that this module and its members and executables
depend on in order to run correctly. This differs from the self.dependencies attribute
that just hase explicit module names from the 'use' clauses. | 5.840151 | 5.178516 | 1.127765 |
if not self.precompile:
return self.filepath
else:
if self._compile_path is None:
segs = self.filepath.split('.')
segs.pop()
segs.append("F90")
self._compile_path = '.'.join(segs)
return self._c... | def compile_path(self) | Returns the file path to this module taking the pre-processing into account.
If the module requires pre-processing, the extension is reported as F90; otherwise,
the regular self.filepath is returned. | 3.772444 | 2.718736 | 1.387573 |
if "private" not in self.modifiers:
def public_collection(attribute):
for key in self.collection(attribute):
if key not in self.publics:
self.publics[key.lower()] = 1
public_collection("members")
public_coll... | def all_to_public(self) | Sets all members, types and executables in this module as public as
long as it doesn't already have the 'private' modifier. | 6.064225 | 4.214943 | 1.438744 |
#Most of the module is body, since that includes everything inside
#of the module ... end module keywords. Since docstrings are handled
#at a higher level by line parser, we only need to deal with the body
#Changes of module name are so rare that we aren't going to bother with t... | def rt_update(self, statement, linenum, mode, modulep, lineparser) | Uses the specified line parser to parse the given statement.
:arg statement: a string of lines that are part of a single statement.
:arg linenum: the line number of the first line in the statement relative to
the entire module contents.
:arg mode: either 'insert', 'replace' or 'delete... | 14.995049 | 15.358754 | 0.976319 |
self.parent = parent
self._unpickle_collection(self.members)
self._unpickle_collection(self.executables)
self._unpickle_collection(self.types) | def unpickle(self, parent) | Sets the parent pointer references for the module *and* all of its
child classes that also have pointer references. | 4.500546 | 4.016851 | 1.120417 |
for depend in self.dependencies:
if "." in depend:
#We know the module name and the executable name, easy
if depend.split(".")[1] == symbol.lower():
found = self.parent.get_executable(depend)
break
else:
... | def get_dependency_element(self, symbol) | Checks if the specified symbol is the name of one of the methods
that this module depends on. If it is, search for the actual code
element and return it. | 3.70507 | 3.518521 | 1.053019 |
possible = []
for ekey in self.collection(attribute):
if symbol in ekey:
possible.append(ekey)
#Try this out on all the dependencies as well to find all the possible
#completions.
if recursive:
for depkey in self.dependencies:
... | def completions(self, symbol, attribute, recursive = False) | Finds all possible symbol completions of the given symbol that belong
to this module and its dependencies.
:arg symbol: the code symbol that needs to be completed.
:arg attribute: one of ['dependencies', 'publics', 'members',
'types', 'executables'] for specifying which collections t... | 6.70377 | 6.711529 | 0.998844 |
if self._contains_index is None:
max_t = 0
for tkey in self.types:
if self.types[tkey].end > max_t and not self.types[tkey].embedded:
max_t = self.types[tkey].end
#Now we have a good first guess. Continue to iterate the next few l... | def contains_index(self) | Returns the *line number* that has the CONTAINS keyword separating the
member and type definitions from the subroutines and functions. | 4.786372 | 4.327637 | 1.106001 |
result = []
for dep in self.dependencies:
module = dep.split(".")[0].lower()
if module not in result:
result.append(module)
return result | def needs(self) | Returns a unique list of module names that this module depends on. | 4.553617 | 3.092559 | 1.472443 |
result = {}
for key in self.executables:
if (isinstance(self.executables[key], Subroutine) and isSubroutine) or \
(isinstance(self.executables[key], Function) and not isSubroutine):
result[key] = self.executables[key]
return result | def _filter_execs(self, isSubroutine) | Filters the executables in the dictionary by their type. | 2.253549 | 1.853917 | 1.215561 |
super(CodeElement, self).warn(collection)
if not "implicit none" in self.modifiers:
collection.append("WARNING: implicit none not set in {}".format(self.name)) | def warn(self, collection) | Checks the module for documentation and best-practice warnings. | 10.134473 | 9.297924 | 1.089972 |
return self.parent.type_search(basetype, symbolstr, self) | def type_search(self, basetype, symbolstr) | Recursively traverses the module trees looking for the final
code element in a sequence of %-separated symbols.
:arg basetype: the type name of the first element in the symbol string.
:arg symblstr: a %-separated list of symbols, e.g. this%sym%sym2%go. | 5.34738 | 12.116996 | 0.441312 |
return {
"dependencies": self.dependencies,
"publics": self.publics,
"members": self.members,
"types": self.types,
"executables": self.executables,
"interfaces": self.interfaces
}[attribute] | def collection(self, attribute) | Returns the collection corresponding the attribute name. | 4.100439 | 3.454246 | 1.187072 |
self.refstring = string
self._lines = []
self._contains_index = None
self.changed = True
#The only other references that become out of date are the contains
#and preamble attributes which are determined by the parsers.
#Assuming we did everything right w... | def update_refstring(self, string) | Updates the refstring that represents the original string that
the module was parsed from. Also updates any properties or attributes
that are derived from the refstring. | 11.230433 | 10.815761 | 1.03834 |
target = self.charindex(line, column) + charcount
#We are looking for all the instances whose *start* attribute lies
#after this target. Then we update them all by that amount.
#However, we need to be careful because of docdelta. If an elements
#docstring contains the t... | def update_elements(self, line, column, charcount, docdelta=0) | Updates all the element instances that are children of this module
to have new start and end charindex values based on an operation that
was performed on the module source code.
:arg line: the line number of the *start* of the operation.
:arg column: the column number of the start of th... | 5.205828 | 4.935402 | 1.054793 |
if docdelta != 0:
if (element.docstart <= target and
element.docend >= target - docdelta):
return True
else:
return element.absstart > target
else:
return element.absstart > target | def _update_char_check(self, element, target, docdelta) | Checks whether the specified element should have its character indices
updated as part of real-time updating. | 4.734309 | 4.477345 | 1.057392 |
element.start += charcount
element.docstart += charcount
element.end += charcount
element.docend += charcount | def _element_charfix(self, element, charcount) | Updates the start and end attributes by charcount for the element. | 4.736617 | 3.57469 | 1.325043 |
ichar = self.charindex(line, column)
icontains = self.contains_index
result = None
if line < icontains:
#We only need to search through the types and members.
maxstart = 0
tempresult = None
for t in self.types:
if ... | def get_element(self, line, column) | Gets the instance of the element who owns the specified line
and column. | 3.415049 | 3.352994 | 1.018508 |
#The parser doesn't handle embeddings deeper than two levels.
coll = self.collection(attribute)
keys = list(coll.keys())
for key in keys:
element = coll[key]
new_parent = self.find_embedded_parent(element)
if new_parent is not None:
... | def update_embedded(self, attribute) | Updates the elements in the module 'result' that have character indices
that are a subset of another element. These correspond to cases where the
type or subroutine is declared within another subroutine.
:attr attribute: the name of the collection to update over. | 4.750782 | 4.433383 | 1.071593 |
result = None
for t in self.types:
if (element.start > self.types[t].start and
element.end < self.types[t].end):
result = self.types[t]
break
else:
for iexec in self.executables:
if (element.start > ... | def find_embedded_parent(self, element) | Finds the parent (if any) of the embedded element by seeing
if the start and end indices of the element are a subset of
any type or executable in this module. | 2.338236 | 1.852621 | 1.262123 |
#Make sure that we have chars and lines to work from if this
#gets called before linenum() does.
if len(self._lines) == 0:
self.linenum(1)
if line < len(self._chars):
return self._chars[line - 1] + column
else:
return len(self.refstri... | def charindex(self, line, column) | Gets the absolute character index of the line and column
in the continuous string. | 7.774181 | 7.502154 | 1.03626 |
if len(self._lines) == 0 and self.refstring != "":
self._lines = self.refstring.split("\n")
#Add one for the \n that we split on for each line
self._chars = [ len(x) + 1 for x in self._lines ]
#Remove the last line break since it doesn't exist
... | def linenum(self, index) | Gets the line number of the character at the specified index.
If the result is unknown, -1 is returned. | 3.816859 | 3.779122 | 1.009985 |
for k,input in self.inputs.items():
if k in self.valid_opts:
for param in self.valid_opts[k]:
if param is None or input is None:
return True
elif type(param) is str and '+' in param:
if re.search(r'^'+param,str(input)):
return True
elif type(param) is bool and type(input) i... | def check_valid(self) | check if input is valid | 2.752397 | 2.684556 | 1.025271 |
if self.inputs is not None:
for k,v in defaultHeaders.items():
if k not in self.inputs:
self.inputs[k] = v
return self.inputs
else:
return self.inputs | def update_policy(self,defaultHeaders) | if policy in default but not input still return | 2.530011 | 2.352411 | 1.075497 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.