input
stringlengths
11
5.29k
target
stringlengths
20
8.26k
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def __init__(self, backup_dir, output_file, compression='none', verbose=False, binary="tar"): super(TarThread, self).__init__(self.__class__.__name__, compression) self.compression_method = compression self.backup_dir = backup_dir self.output_file = output_file self.verbose = verbose self.binary = binary self._command = None
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def __init__(self): if _debug: ReadWritePropertyServices._debug("__init__") Capability.__init__(self)
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def __init__(self): if _debug: ReadWritePropertyMultipleServices._debug("__init__") Capability.__init__(self)
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def __init__(self, *args, **kwargs): logSetup.initLogging() super().__init__(*args, **kwargs)
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def __init__(self): super().__init__() self.visited = []
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def __init__(self): super().__init__() self.recorded_access_path = None
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def __init__(self, strand_item: PathStrandItemT, cap_type: str, # low, high, dual is_drawn5to3: bool): """The parent should be a StrandItem.""" super(EndpointItem, self).__init__(strand_item.virtualHelixItem()) self._strand_item = strand_item self._getActiveTool = strand_item._getActiveTool self.cap_type = cap_type self._low_drag_bound = None self._high_drag_bound = None self._mod_item = None self._isdrawn5to3 = is_drawn5to3 self._initCapSpecificState(is_drawn5to3) p = QPen() p.setCosmetic(True) self.setPen(p) # for easier mouseclick self._click_area = cA = QGraphicsRectItem(_DEFAULT_RECT, self) self._click_area.setAcceptHoverEvents(True) cA.hoverMoveEvent = self.hoverMoveEvent cA.mousePressEvent = self.mousePressEvent cA.mouseMoveEvent = self.mouseMoveEvent cA.setPen(_NO_PEN) self.setFlag(QGraphicsItem.ItemIsSelectable)
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def get_coil_config_section(cls): """Return coil config section.""" return "opp_coils"
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def __init__(self, function): self.function = function
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def __init__(self, domain, image, parent, capacity, format, type, voltype, disktype, description="", legality=sc.ILLEGAL_VOL, ctime=None, generation=sc.DEFAULT_GENERATION, sequence=sc.DEFAULT_SEQUENCE): # Storage domain UUID self.domain = domain # Image UUID self.image = image # UUID of the parent volume or BLANK_UUID self.parent = parent # Volume capacity in bytes self.capacity = capacity # Format (RAW or COW) self.format = format # Allocation policy (PREALLOCATED or SPARSE) self.type = type # Relationship to other volumes (LEAF, INTERNAL or SHARED) self.voltype = voltype # Intended usage of this volume (unused) self.disktype = disktype # Free-form description and may be used to store extra metadata self.description = description # Indicates if the volume contents should be considered valid self.legality = legality # Volume creation time (in seconds since the epoch) self.ctime = int(time.time()) if ctime is None else ctime # Generation increments each time certain operations complete self.generation = generation # Sequence number of the volume, increased every time a new volume is # created in an image. self.sequence = sequence
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def __rlshift__(self, other): return Infix(lambda x, self=self, other=other: self.function(other, x))
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def __rshift__(self, other): return self.function(other)
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def generation(self, value): self._generation = self._validate_integer("generation", value)
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def __init__(self, public_ip_api, api_ip, domain, user, password, cascading_domain, cascading_api_ip, cascaded_domain, cascaded_api_ip, cascaded_api_subnet_gateway): self.public_ip_api = public_ip_api self.api_ip = api_ip self.domain = domain self.user = user self.password = password self.cascading_domain = cascading_domain self.cascading_api_ip = cascading_api_ip self.cascaded_domain = cascaded_domain self.cascaded_ip = cascaded_api_ip self.gateway = cascaded_api_subnet_gateway
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def __init__(self, default=None): self.default = default list.__init__(self)
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def __init__(self,age): self.age = age
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def separator(self, inc_sep): ''' setter method for separator ''' self._separator = inc_sep
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def __init__(self, namespace, kubeconfig='/etc/origin/master/admin.kubeconfig', verbose=False, all_namespaces=False): ''' Constructor for OpenshiftCLI ''' self.namespace = namespace self.verbose = verbose self.kubeconfig = Utils.create_tmpfile_copy(kubeconfig) self.all_namespaces = all_namespaces self.oc_binary = locate_oc_binary()
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def __init__(self, content): '''secret constructor''' super(Secret, self).__init__(content=content) self._secrets = None
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def __init__(self, sname, namespace, ports, selector=None, labels=None, cluster_ip=None, portal_ip=None, session_affinity=None, service_type=None, external_ips=None): ''' constructor for handling service options ''' self.name = sname self.namespace = namespace self.ports = ports self.selector = selector self.labels = labels self.cluster_ip = cluster_ip self.portal_ip = portal_ip self.session_affinity = session_affinity self.service_type = service_type self.external_ips = external_ips self.data = {} self.create_dict()
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def __init__(self, content): '''Service constructor''' super(Service, self).__init__(content=content)
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def __init__(self, config, debug): ''' Constructor for OCVersion ''' super(OCVersion, self).__init__(None, config) self.debug = debug
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def __init__(self, rname, namespace, kubeconfig, registry_options): super(RegistryConfig, self).__init__(rname, namespace, kubeconfig, registry_options)
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def __init__(self, col2): self.col2 = col2
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def __init__ (self, url=None, scheduler='default', session=None) : Attributes.__init__ (self)
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def __init__(self, *requirements): self._requirements = set(requirements)
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def __iter__(self): return iter(self._requirements)
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def __init__(self, editwin): self.editwin = editwin # Provide instance variables referenced by Debugger # XXX This should be done differently self.flist = self.editwin.flist self.root = self.editwin.root
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def __init__(self, stream_parser, message): self._stream_parser = stream_parser self._message = message self._iter_rows = None self._num_items = self._message.row_count self._remaining = self._message.row_count
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def is_user_addon(mod, user_addon_paths): import os if not user_addon_paths: for path in (bpy.utils.script_path_user(), bpy.utils.script_path_pref()): if path is not None: user_addon_paths.append(os.path.join(path, "addons")) for path in user_addon_paths: if bpy.path.is_subdir(mod.__file__, path): return True return False
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def archbin(self): """Relative location of architecture-specific executables""" return join_path('platforms', self.foam_arch, 'bin')
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def archlib(self): """Relative location of architecture-specific libraries""" return join_path('platforms', self.foam_arch, 'lib')
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def loaded(cls): return 'cudf' in sys.modules
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def get_subdirectory(cls, location): """ Return the path to setup.py, relative to the repo root. Return None if setup.py is in the repo root. """ # find the repo root git_dir = cls.run_command( ['rev-parse', '--git-dir'], show_stdout=False, stdout_only=True, cwd=location, ).strip() if not os.path.isabs(git_dir): git_dir = os.path.join(location, git_dir) repo_root = os.path.abspath(os.path.join(git_dir, '..')) return find_path_to_setup_from_repo_root(location, repo_root)
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def GetCompletions_NoSuggestions_Fallback_test( app ): # Python completer doesn't raise NO_COMPLETIONS_MESSAGE, so this is a # different code path to the Clang completer cases # TESTCASE2 (general_fallback/lang_python.py) RunTest( app, { 'description': 'param jedi does not know about (id). query="a_p"', 'request': { 'filetype' : 'python', 'filepath' : PathToTestFile( 'general_fallback', 'lang_python.py' ), 'line_num' : 28, 'column_num': 20, 'force_semantic': False, }, 'expect': { 'response': http.client.OK, 'data': has_entries( { 'completions': contains( CompletionEntryMatcher( 'a_parameter', '[ID]' ), CompletionEntryMatcher( 'another_parameter', '[ID]' ), ), 'errors': empty(), } ) }, } )
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def enable_plugin(plugin): plugin = get_plugin_from_all(plugin) if plugin.enabled: flash(_("Plugin %(plugin)s is already enabled.", plugin=plugin.name), "info") return redirect(url_for("management.plugins")) try: plugin.enable() flash(_("Plugin %(plugin)s enabled. Please restart FlaskBB now.", plugin=plugin.name), "success") except OSError: flash(_("It seems that FlaskBB does not have enough filesystem " "permissions. Try removing the 'DISABLED' file by " "yourself instead."), "danger") return redirect(url_for("management.plugins"))
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def finalize_options(self): ret = InstallCommandBase.finalize_options(self) self.install_headers = os.path.join(self.install_purelib, 'tensorflow', 'include') return ret
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def run(self): hdrs = self.distribution.headers if not hdrs: return self.mkpath(self.install_dir) for header in hdrs: (out, _) = self.mkdir_and_copy_file(header) self.outfiles.append(out)
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def getDriver(self): chromeDriverExeFilePath = "cameo_res\\chromedriver.exe" driver = webdriver.Chrome(chromeDriverExeFilePath) return driver
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def do_mods(self, s): print(sys.modules.keys())
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def deletePyc(self, only_excess = True): for root, dirs, files in os.walk(ss(Env.get('app_dir'))): pyc_files = filter(lambda filename: filename.endswith('.pyc'), files) py_files = set(filter(lambda filename: filename.endswith('.py'), files)) excess_pyc_files = filter(lambda pyc_filename: pyc_filename[:-1] not in py_files, pyc_files) if only_excess else pyc_files for excess_pyc_file in excess_pyc_files: full_path = os.path.join(root, excess_pyc_file) log.debug('Removing old PYC file: %s', full_path) try: os.remove(full_path) except: log.error('Couldn\'t remove %s: %s', (full_path, traceback.format_exc())) for dir_name in dirs: full_path = os.path.join(root, dir_name) if len(os.listdir(full_path)) == 0: try: os.rmdir(full_path) except: log.error('Couldn\'t remove empty directory %s: %s', (full_path, traceback.format_exc()))
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def attribs(name): mod = import_module(name) print name print 'Has __all__?', hasattr(mod, '__all__') print 'Has __doc__?', hasattr(mod, '__doc__') print 'doc: ', getdoc(mod)
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def locate_oc_binary(): ''' Find and return oc binary file ''' # https://github.com/openshift/openshift-ansible/issues/3410 # oc can be in /usr/local/bin in some cases, but that may not # be in $PATH due to ansible/sudo paths = os.environ.get("PATH", os.defpath).split(os.pathsep) + ADDITIONAL_PATH_LOOKUPS oc_binary = 'oc' # Use shutil.which if it is available, otherwise fallback to a naive path search try: which_result = shutil.which(oc_binary, path=os.pathsep.join(paths)) if which_result is not None: oc_binary = which_result except AttributeError: for path in paths: if os.path.exists(os.path.join(path, oc_binary)): oc_binary = os.path.join(path, oc_binary) break return oc_binary
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def sys_path(): import sys print(sys.path)
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def checksyntax(self, filename): self.shell = shell = self.flist.open_shell() saved_stream = shell.get_warning_stream() shell.set_warning_stream(shell.stderr) f = open(filename, 'r') source = f.read() f.close() if '\r' in source: source = re.sub(r"\r\n", "\n", source) source = re.sub(r"\r", "\n", source) if source and source[-1] != '\n': source = source + '\n' text = self.editwin.text text.tag_remove("ERROR", "1.0", "end") try: try: # If successful, return the compiled code return compile(source, filename, "exec") except (SyntaxError, OverflowError), err: try: msg, (errorfilename, lineno, offset, line) = err if not errorfilename: err.args = msg, (filename, lineno, offset, line) err.filename = filename self.colorize_syntax_error(msg, lineno, offset) except: msg = "*** " + str(err) self.errorbox("Syntax error", "There's an error in your program:\n" + msg) return False finally: shell.set_warning_stream(saved_stream)
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def _get_exporter(): from pyqtgraph.exporters.SVGExporter import SVGExporter return SVGExporter
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def graphviz_setup(gviz_path): os.environ['PATH'] = gviz_path + ";" + os.environ['PATH']
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def copy_clfftdll_to_package(): import shutil shutil.copy( os.path.join(CLFFT_DIR, 'bin', 'clFFT.dll'), 'gpyfft') shutil.copy( os.path.join(CLFFT_DIR, 'bin', 'StatTimer.dll'), 'gpyfft') print("copied clFFT.dll, StatTimer.dll")
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def get_version(): main_ns = {} version_path = convert_path('gpyfft/version.py') with open(version_path) as version_file: exec(version_file.read(), main_ns) version = main_ns['__version__'] return version
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def load_source(module_name, module_path): """Loads a python module from the path of the corresponding file.""" if sys.version_info[0] == 3 and sys.version_info[1] >= 5: import importlib.util spec = importlib.util.spec_from_file_location(module_name, module_path) module = importlib.util.module_from_spec(spec) spec.loader.exec_module(module) elif sys.version_info[0] == 3 and sys.version_info[1] < 5: import importlib.machinery loader = importlib.machinery.SourceFileLoader(module_name, module_path) module = loader.load_module() return module
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def get_callable_handler_function(src, handler): """Translate a string of the form "module.function" into a callable function. :param str src: The path to your Lambda project containing a valid handler file. :param str handler: A dot delimited string representing the `<module>.<function name>`. """ # "cd" into `src` directory. os.chdir(src) module_name, function_name = handler.split(".") filename = get_handler_filename(handler) path_to_module_file = os.path.join(src, filename) module = load_source(module_name, path_to_module_file) return getattr(module, function_name)
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def _filter_blacklist(package): blacklist = ["-i", "#", "Python==", "python-lambda=="] return all(package.startswith(entry) is False for entry in blacklist)
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def pip_install_to_target(path, requirements=None, local_package=None): """For a given active virtualenv, gather all installed pip packages then copy (re-install) them to the path provided. :param str path: Path to copy installed pip packages to. :param str requirements: If set, only the packages in the supplied requirements file are installed. If not set then installs all packages found via pip freeze. :param str local_package: The path to a local package with should be included in the deploy as well (and/or is not available on PyPi) """ packages = [] if not requirements: print("Gathering pip packages") pkgStr = subprocess.check_output( [sys.executable, "-m", "pip", "freeze"] ) packages.extend(pkgStr.decode("utf-8").splitlines()) else: if os.path.exists(requirements): print("Gathering requirement packages") data = read(requirements) packages.extend(data.splitlines()) if not packages: print("No dependency packages installed!") if local_package is not None: if not isinstance(local_package, (list, tuple)): local_package = [local_package] for l_package in local_package: packages.append(l_package) _install_packages(path, packages)
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def get_output_format(opt): if opt.output_file_format == 'excel': try: import openpyxl except ImportError: sys.stdout.write("Unable to write Excel files: resorting to csv format.\n") opt.output_file_format = 'csv' if opt.output_file_format == 'csv': opt.output_filename_ext = '.csv' opt.csv_format = {'dialect': 'excel', 'lineterminator': '\n'} if opt.csv_delimiter == 'tab': opt.csv_format['delimiter'] = '\t' if opt.output_filename_date_suffix: from datetime import date opt.output_filename_suffix = "." + date.today().isoformat() if opt.output_filename_other_suffix != '': opt.output_filename_suffix += "." + opt.output_filename_other_suffix
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def _isPython(self, path): return path.endswith('.py') or path.endswith('.pyc')
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def _isPythonModuleCandidate(self, path): return path.endswith('.so') or self._isPython(path)
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def _runPythonScript(self, binPath, destdir, libdir, scriptLines): script = '\n'.join(scriptLines) environ = {} if binPath.startswith(destdir): environ['LD_LIBRARY_PATH'] = destdir + libdir proc = subprocess.Popen([binPath, '-Ec', script], executable=binPath, stdout=subprocess.PIPE, shell=False, env=environ, ) stdout, _ = proc.communicate() if proc.returncode: raise RuntimeError("Process exited with status %s" % (proc.returncode,)) return stdout
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def _getPythonVersion(self, pythonPath, destdir, libdir): if pythonPath not in self.pythonVersionCache: try: stdout = self._runPythonScript(pythonPath, destdir, libdir, ["import sys", "print('%d.%d' % sys.version_info[:2])"]) self.pythonVersionCache[pythonPath] = stdout.strip() except (OSError, RuntimeError): self.warn("Unable to determine Python version directly; " "guessing based on path.") self.pythonVersionCache[pythonPath] = self._getPythonVersionFromPath(pythonPath, destdir) return self.pythonVersionCache[pythonPath]
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def _getPythonSysPath(self, pythonPath, destdir, libdir, useDestDir=False): """Return the system path for the python interpreter at C{pythonPath} @param pythonPath: Path to the target python interpreter @param destdir: Destination root, in case of a python bootstrap @param libdir: Destination libdir, in case of a python bootstrap @param useDestDir: If True, look in the destdir instead. """ script = ["import sys, site"] if useDestDir: # Repoint site.py at the destdir so it picks up .pth files there. script.extend([ "sys.path = []", "sys.prefix = %r + sys.prefix" % (destdir,), "sys.exec_prefix = %r + sys.exec_prefix" % (destdir,), "site.PREFIXES = [sys.prefix, sys.exec_prefix]", "site.addsitepackages(None)", ]) script.append(r"print('\0'.join(sys.path))") try: stdout = self._runPythonScript(pythonPath, destdir, libdir, script) except (OSError, RuntimeError): # something went wrong, don't trust any output self.info('Could not run system python "%s", guessing sys.path...', pythonPath) sysPath = [] else: sysPath = [x.strip() for x in stdout.split('\0') if x.strip()] if not sysPath and not useDestDir: # probably a cross-build -- let's try a decent assumption # for the syspath. self.info("Failed to detect system python path, using fallback") pyVer = self._getPythonVersionFromPath(pythonPath, destdir) if not pyVer and self.bootstrapPythonFlags is not None: pyVer = self._getPythonVersionFromFlags( self.bootstrapPythonFlags) if pyVer and self.bootstrapSysPath is not None: lib = self.recipe.macros.lib # this list needs to include all sys.path elements that # might be needed for python per se -- note that # bootstrapPythonFlags and bootstrapSysPath go # together sysPath = self.bootstrapSysPath + [ '/usr/%s/%s' %(lib, pyVer), '/usr/%s/%s/plat-linux2' %(lib, pyVer), '/usr/%s/%s/lib-tk' %(lib, pyVer), '/usr/%s/%s/lib-dynload' %(lib, pyVer), '/usr/%s/%s/site-packages' %(lib, pyVer), # for purelib python on x86_64 '/usr/lib/%s/site-packages' %pyVer, ] return sysPath
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def _warnPythonPathNotInDB(self, pathName): self.warn('%s found on system but not provided by' ' system database; python requirements' ' may be generated incorrectly as a result', pathName) return set([])
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def _getPythonTroveFlags(self, pathName): if pathName in self.pythonTroveFlagCache: return self.pythonTroveFlagCache[pathName] db = self._getDb() foundPath = False pythonFlags = set() pythonTroveList = db.iterTrovesByPath(pathName) if pythonTroveList: depContainer = pythonTroveList[0] assert(depContainer.getName()) foundPath = True for dep in depContainer.getRequires().iterDepsByClass( deps.PythonDependencies): flagNames = [x[0] for x in dep.getFlags()[0]] pythonFlags.update(flagNames) self.pythonTroveFlagCache[pathName] = pythonFlags if not foundPath: self.pythonTroveFlagCache[pathName] = self._warnPythonPathNotInDB( pathName) return self.pythonTroveFlagCache[pathName]
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def _getPythonFlags(self, pathName, bootstrapPythonFlags=None): if pathName in self.pythonFlagCache: return self.pythonFlagCache[pathName] if bootstrapPythonFlags: self.pythonFlagCache[pathName] = bootstrapPythonFlags return self.pythonFlagCache[pathName] db = self._getDb() foundPath = False # FIXME: This should be iterFilesByPath when implemented (CNY-1833) # For now, cache all the python deps in all the files in the # trove(s) so that we iterate over each trove only once containingTroveList = db.iterTrovesByPath(pathName) for containerTrove in containingTroveList: for pathid, p, fileid, v in containerTrove.iterFileList(): if pathName == p: foundPath = True pythonFlags = set() f = files.ThawFile(db.getFileStream(fileid), pathid) for dep in f.provides().iterDepsByClass( deps.PythonDependencies): flagNames = [x[0] for x in dep.getFlags()[0]] pythonFlags.update(flagNames) self.pythonFlagCache[p] = pythonFlags if not foundPath: self.pythonFlagCache[pathName] = self._warnPythonPathNotInDB( pathName) return self.pythonFlagCache[pathName]
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def _getPythonFlagsFromPath(self, pathName): pathList = pathName.split('/') foundLib = False foundVer = False flags = set() for dirName in pathList: if not foundVer and not foundLib and dirName.startswith('lib'): # lib will always come before ver foundLib = True flags.add(dirName) elif not foundVer and dirName.startswith('python'): foundVer = True flags.add(dirName[6:]) if foundLib and foundVer: break if self.pythonFlagNamespace: flags = set('%s:%s' %(self.pythonFlagNamespace, x) for x in flags) return flags
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def _getPythonVersionFromFlags(self, flags): nameSpace = self.pythonFlagNamespace for flag in flags: if nameSpace and flag.startswith(nameSpace): flag = flag[len(nameSpace):] if self._stringIsPythonVersion(flag): return 'python'+flag
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def _getPythonVersionFromPath(self, pathName, destdir): if destdir and pathName.startswith(destdir): pathName = pathName[len(destdir):] pathList = pathName.split('/') for dirName in pathList: if dirName.startswith('python') and self._stringIsPythonVersion( dirName[6:]): # python2.4 or python2.5 or python3.9 but not python.so return dirName return ''
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def _isPerl(self, path, m, f): return self._isPerlModule(path) or ( f.inode.perms() & 0111 and m and m.name == 'script' and 'interpreter' in m.contents and '/bin/perl' in m.contents['interpreter'])
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def _addDepToMap(self, path, depMap, depType, dep): "Add a single dependency to a map, regardless of whether path was listed before" if path not in depMap: depMap[path] = deps.DependencySet() depMap[path].addDep(depType, dep)
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def _addDepSetToMap(self, path, depMap, depSet): "Add a dependency set to a map, regardless of whether path was listed before" if path in depMap: depMap[path].union(depSet) else: depMap[path] = depSet
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def _getRuby(self, macros, path): # For bootstrapping purposes, prefer the just-built version if # it exists # Returns tuple: (pathToRubyInterpreter, bootstrap) ruby = '%(ruby)s' %macros if os.access('%(destdir)s/%(ruby)s' %macros, os.X_OK): return '%(destdir)s/%(ruby)s' %macros, True elif os.access(ruby, os.X_OK): # Enforce the build requirement, since it is not in the package self._enforceProvidedPath(ruby) return ruby, False else: self.warn('%s not available for Ruby dependency discovery' ' for path %s' %(ruby, path)) return False, None
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def _getRubyVersion(self, macros): cmd = self.rubyInvocation + (" -e 'puts RUBY_VERSION'" % macros) rubyVersion = util.popen(cmd).read() rubyVersion = '.'.join(rubyVersion.split('.')[0:2]) return rubyVersion
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def _getRubyFlagsFromPath(self, pathName, rubyVersion): pathList = pathName.split('/') pathList = [ x for x in pathList if x ] foundLib = False foundVer = False flags = set() for dirName in pathList: if not foundLib and dirName.startswith('lib'): foundLib = True flags.add(dirName) elif not foundVer and dirName.split('.')[:1] == rubyVersion.split('.')[:1]: # we only compare major and minor versions due to # ruby api version (dirName) differing from programs # version (rubyVersion) foundVer = True flags.add(dirName) if foundLib and foundVer: break return flags
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def _getmonodis(self, macros, path): # For bootstrapping purposes, prefer the just-built version if # it exists monodis = '%(monodis)s' %macros if os.access('%(destdir)s/%(monodis)s' %macros, os.X_OK): return ('MONO_PATH=%(destdir)s%(prefix)s/lib' ' LD_LIBRARY_PATH=%(destdir)s%(libdir)s' ' %(destdir)s/%(monodis)s' %macros) elif os.access(monodis, os.X_OK): # Enforce the build requirement, since it is not in the package self._enforceProvidedPath(monodis) return monodis else: self.warn('%s not available for CIL dependency discovery' ' for path %s' %(monodis, path)) return None
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
async def async_reload_entry(hass: HomeAssistant, entry: ConfigEntry) -> None: """Handle an options update.""" await hass.config_entries.async_reload(entry.entry_id)
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def from_envvar(self, variable_name: str, silent: bool = False) -> bool: """Loads a configuration from an environment variable pointing to a configuration file. This is basically just a shortcut with nicer error messages for this line of code:: app.config.from_pyfile(os.environ['YOURAPPLICATION_SETTINGS']) :param variable_name: name of the environment variable :param silent: set to ``True`` if you want silent failure for missing files. :return: bool. ``True`` if able to load config, ``False`` otherwise. """ rv = os.environ.get(variable_name) if not rv: if silent: return False raise RuntimeError( f"The environment variable {variable_name!r} is not set" " and as such configuration could not be loaded. Set" " this variable and make it point to a configuration" " file" ) return self.from_pyfile(rv, silent=silent)
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def from_pyfile(self, filename: str, silent: bool = False) -> bool: """Updates the values in the config from a Python file. This function behaves as if the file was imported as module with the :meth:`from_object` function. :param filename: the filename of the config. This can either be an absolute filename or a filename relative to the root path. :param silent: set to ``True`` if you want silent failure for missing files. .. versionadded:: 0.7 `silent` parameter. """ filename = os.path.join(self.root_path, filename) d = types.ModuleType("config") d.__file__ = filename try: with open(filename, mode="rb") as config_file: exec(compile(config_file.read(), filename, "exec"), d.__dict__) except OSError as e: if silent and e.errno in (errno.ENOENT, errno.EISDIR, errno.ENOTDIR): return False e.strerror = f"Unable to load configuration file ({e.strerror})" raise self.from_object(d) return True
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def from_object(self, obj: t.Union[object, str]) -> None: """Updates the values from the given object. An object can be of one of the following two types: - a string: in this case the object with that name will be imported - an actual object reference: that object is used directly Objects are usually either modules or classes. :meth:`from_object` loads only the uppercase attributes of the module/class. A ``dict`` object will not work with :meth:`from_object` because the keys of a ``dict`` are not attributes of the ``dict`` class. Example of module-based configuration:: app.config.from_object('yourapplication.default_config') from yourapplication import default_config app.config.from_object(default_config) Nothing is done to the object before loading. If the object is a class and has ``@property`` attributes, it needs to be instantiated before being passed to this method. You should not use this function to load the actual configuration but rather configuration defaults. The actual config should be loaded with :meth:`from_pyfile` and ideally from a location not within the package because the package might be installed system wide. See :ref:`config-dev-prod` for an example of class-based configuration using :meth:`from_object`. :param obj: an import name or object """ if isinstance(obj, str): obj = import_string(obj) for key in dir(obj): if key.isupper(): self[key] = getattr(obj, key)
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def from_file( self, filename: str, load: t.Callable[[t.IO[t.Any]], t.Mapping], silent: bool = False, ) -> bool: """Update the values in the config from a file that is loaded using the ``load`` parameter. The loaded data is passed to the :meth:`from_mapping` method. .. code-block:: python import toml app.config.from_file("config.toml", load=toml.load) :param filename: The path to the data file. This can be an absolute path or relative to the config root path. :param load: A callable that takes a file handle and returns a mapping of loaded data from the file. :type load: ``Callable[[Reader], Mapping]`` where ``Reader`` implements a ``read`` method. :param silent: Ignore the file if it doesn't exist. .. versionadded:: 2.0 """ filename = os.path.join(self.root_path, filename) try: with open(filename) as f: obj = load(f) except OSError as e: if silent and e.errno in (errno.ENOENT, errno.EISDIR): return False e.strerror = f"Unable to load configuration file ({e.strerror})" raise return self.from_mapping(obj)
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def from_json(self, filename: str, silent: bool = False) -> bool: """Update the values in the config from a JSON file. The loaded data is passed to the :meth:`from_mapping` method. :param filename: The path to the JSON file. This can be an absolute path or relative to the config root path. :param silent: Ignore the file if it doesn't exist. .. deprecated:: 2.0.0 Will be removed in Flask 2.1. Use :meth:`from_file` instead. This was removed early in 2.0.0, was added back in 2.0.1. .. versionadded:: 0.11 """ import warnings from . import json warnings.warn( "'from_json' is deprecated and will be removed in Flask" " 2.1. Use 'from_file(path, json.load)' instead.", DeprecationWarning, stacklevel=2, ) return self.from_file(filename, json.load, silent=silent)
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def from_mapping( self, mapping: t.Optional[t.Mapping[str, t.Any]] = None, **kwargs: t.Any ) -> bool: """Updates the config like :meth:`update` ignoring items with non-upper keys. .. versionadded:: 0.11 """ mappings: t.Dict[str, t.Any] = {} if mapping is not None: mappings.update(mapping) mappings.update(kwargs) for key, value in mappings.items(): if key.isupper(): self[key] = value return True
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def get_namespace( self, namespace: str, lowercase: bool = True, trim_namespace: bool = True ) -> t.Dict[str, t.Any]: """Returns a dictionary containing a subset of configuration options that match the specified namespace/prefix. Example usage:: app.config['IMAGE_STORE_TYPE'] = 'fs' app.config['IMAGE_STORE_PATH'] = '/var/app/images' app.config['IMAGE_STORE_BASE_URL'] = 'http://img.website.com' image_store_config = app.config.get_namespace('IMAGE_STORE_') The resulting dictionary `image_store_config` would look like:: { 'type': 'fs', 'path': '/var/app/images', 'base_url': 'http://img.website.com' } This is often useful when configuration options map directly to keyword arguments in functions or class constructors. :param namespace: a configuration namespace :param lowercase: a flag indicating if the keys of the resulting dictionary should be lowercase :param trim_namespace: a flag indicating if the keys of the resulting dictionary should not include the namespace .. versionadded:: 0.11 """ rv = {} for k, v in self.items(): if not k.startswith(namespace): continue if trim_namespace: key = k[len(namespace) :] else: key = k if lowercase: key = key.lower() rv[key] = v return rv
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def __init__(self, auth_provider): super(SnapshotsClientJSON, self).__init__(auth_provider) self.service = CONF.volume.catalog_type self.build_interval = CONF.volume.build_interval self.build_timeout = CONF.volume.build_timeout
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def __init__(self): self.supports_check_mode = True self.argument_spec = dict( accept_eula=dict( type='bool', default='no', choices=BOOLEANS ), base_key=dict( required=False, no_log=True ), name=dict( required=True ), state=dict( required=False, default='present', choices=['absent', 'present'] ) ) self.f5_product_name = 'iworkflow'
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def main(): if not HAS_F5SDK: raise F5ModuleError("The python f5-sdk module is required") spec = ArgumentSpec() client = AnsibleF5Client( argument_spec=spec.argument_spec, supports_check_mode=spec.supports_check_mode, f5_product_name=spec.f5_product_name ) try: mm = ModuleManager(client) results = mm.exec_module() client.module.exit_json(**results) except F5ModuleError as e: client.module.fail_json(msg=str(e))
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def draw(self, context): self.layout.operator("wm.appconfig_default", text="Blender (default)") # now draw the presets Menu.draw_preset(self, context)
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
async def pre_process(self, message, data): """ context language variable will be set each time when update from 'process_update_types' comes value is the result of 'get_user_language' method """ self.context_lang.set(await self.get_user_language(obj=message))
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def test_statements(): with pytest.raises(mariofile.ConfigurationFileError): mariofile.parse_section_body(CRASH_MARIOFILE_1.splitlines()) with pytest.raises(mariofile.ConfigurationFileError): mariofile.parse_section_body(CRASH_MARIOFILE_2.splitlines())
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def test_parse_section_body(): output_section = { 'action_template': ' task', 'sources_repls': 'source', 'variable': '6', 'target_pattern': 'target', } assert mariofile.parse_section_body(SECTION.splitlines(True)) == output_section with pytest.raises(mariofile.ConfigurationFileError): mariofile.parse_section_body(SECTION_MULTIPLE_RULE.splitlines(True)) with pytest.raises(mariofile.ConfigurationFileError): mariofile.parse_section_body(INVALID_CONFIG.splitlines(True))
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def mkhead(repo: 'Repo', path: PathLike) -> 'Head': """:return: New branch/head instance""" return git.Head(repo, git.Head.to_full_path(path))
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def write(self) -> None: # type: ignore[override] rval: None = super(SubmoduleConfigParser, self).write() self.flush_to_index() return rval
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def config(self): settings = { # Use SYSTEMMPI since openfoam-org doesn't have USERMPI 'mplib': 'SYSTEMMPI', # Add links into bin/, lib/ (eg, for other applications) 'link': False, } # OpenFOAM v2.4 and earlier lacks WM_LABEL_OPTION if self.spec.satisfies('@:2.4'): settings['label-size'] = False return settings
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def setup_run_environment(self, env): bashrc = self.prefix.etc.bashrc try: env.extend(EnvironmentModifications.from_sourcing_file( bashrc, clean=True )) except Exception as e: msg = 'unexpected error when sourcing OpenFOAM bashrc [{0}]' tty.warn(msg.format(str(e)))
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def setup_dependent_build_environment(self, env, dependent_spec): """Location of the OpenFOAM project directory. This is identical to the WM_PROJECT_DIR value, but we avoid that variable since it would mask the normal OpenFOAM cleanup of previous versions. """ env.set('FOAM_PROJECT_DIR', self.projectdir)
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def setup_dependent_run_environment(self, env, dependent_spec): """Location of the OpenFOAM project directory. This is identical to the WM_PROJECT_DIR value, but we avoid that variable since it would mask the normal OpenFOAM cleanup of previous versions. """ env.set('FOAM_PROJECT_DIR', self.projectdir)
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def rename_source(self): """This is fairly horrible. The github tarfiles have weird names that do not correspond to the canonical name. We need to rename these, but leave a symlink for spack to work with. """ # Note that this particular OpenFOAM requires absolute directories # to build correctly! parent = os.path.dirname(self.stage.source_path) original = os.path.basename(self.stage.source_path) target = 'OpenFOAM-{0}'.format(self.version) # Could also grep through etc/bashrc for WM_PROJECT_VERSION with working_dir(parent): if original != target and not os.path.lexists(target): os.rename(original, target) os.symlink(target, original) tty.info('renamed {0} -> {1}'.format(original, target))
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def patch(self): """Adjust OpenFOAM build for spack. Where needed, apply filter as an alternative to normal patching.""" self.rename_source() add_extra_files(self, self.common, self.assets) # Avoid WM_PROJECT_INST_DIR for ThirdParty, site or jobControl. # Use openfoam-site.patch to handle jobControl, site. # # Filtering: bashrc,cshrc (using a patch is less flexible) edits = { 'WM_THIRD_PARTY_DIR': r'$WM_PROJECT_DIR/ThirdParty #SPACK: No separate third-party', 'WM_VERSION': str(self.version), # consistency 'FOAMY_HEX_MESH': '', # This is horrible (unset variable?) } rewrite_environ_files( # Adjust etc/bashrc and etc/cshrc edits, posix=join_path('etc', 'bashrc'), cshell=join_path('etc', 'cshrc'))
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def configure(self, spec, prefix): """Make adjustments to the OpenFOAM configuration files in their various locations: etc/bashrc, etc/config.sh/FEATURE and customizations that don't properly fit get placed in the etc/prefs.sh file (similiarly for csh). """ # Filtering bashrc, cshrc edits = {} edits.update(self.foam_arch.foam_dict()) rewrite_environ_files( # Adjust etc/bashrc and etc/cshrc edits, posix=join_path('etc', 'bashrc'), cshell=join_path('etc', 'cshrc')) # MPI content, with absolute paths user_mpi = mplib_content(spec) # Content for etc/prefs.{csh,sh} self.etc_prefs = { r'MPI_ROOT': spec['mpi'].prefix, # Absolute r'MPI_ARCH_FLAGS': '"%s"' % user_mpi['FLAGS'], r'MPI_ARCH_INC': '"%s"' % user_mpi['PINC'], r'MPI_ARCH_LIBS': '"%s"' % user_mpi['PLIBS'], } # Content for etc/config.{csh,sh}/ files self.etc_config = { 'CGAL': {}, 'scotch': {}, 'metis': {}, 'paraview': [], 'gperftools': [], # Currently unused } if True: self.etc_config['scotch'] = { 'SCOTCH_ARCH_PATH': spec['scotch'].prefix, # For src/parallel/decompose/Allwmake 'SCOTCH_VERSION': 'scotch-{0}'.format(spec['scotch'].version), } if '+metis' in spec: self.etc_config['metis'] = { 'METIS_ARCH_PATH': spec['metis'].prefix, } # Write prefs files according to the configuration. # Only need prefs.sh for building, but install both for end-users if self.etc_prefs: write_environ( self.etc_prefs, posix=join_path('etc', 'prefs.sh'), cshell=join_path('etc', 'prefs.csh')) # Adjust components to use SPACK variants for component, subdict in self.etc_config.items(): # Versions up to 3.0 used an etc/config/component.sh naming # convention instead of etc/config.sh/component if spec.satisfies('@:3.0'): write_environ( subdict, posix=join_path('etc', 'config', component) + '.sh', cshell=join_path('etc', 'config', component) + '.csh') else: write_environ( subdict, posix=join_path('etc', 'config.sh', component), cshell=join_path('etc', 'config.csh', component))
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def build(self, spec, prefix): """Build using the OpenFOAM Allwmake script, with a wrapper to source its environment first. Only build if the compiler is known to be supported. """ self.foam_arch.has_rule(self.stage.source_path) self.foam_arch.create_rules(self.stage.source_path, self) args = [] if self.parallel: # Build in parallel? - pass via the environment os.environ['WM_NCOMPPROCS'] = str(make_jobs) builder = Executable(self.build_script) builder(*args)
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def install(self, spec, prefix): """Install under the projectdir""" mkdirp(self.projectdir) projdir = os.path.basename(self.projectdir) # Filtering: bashrc, cshrc edits = { 'WM_PROJECT_INST_DIR': os.path.dirname(self.projectdir), 'WM_PROJECT_DIR': join_path('$WM_PROJECT_INST_DIR', projdir), } # All top-level files, except spack build info and possibly Allwmake if '+source' in spec: ignored = re.compile(r'^spack-.*') else: ignored = re.compile(r'^(Allwmake|spack-).*') files = [ f for f in glob.glob("*") if os.path.isfile(f) and not ignored.search(f) ] for f in files: install(f, self.projectdir) # Having wmake and ~source is actually somewhat pointless... # Install 'etc' before 'bin' (for symlinks) # META-INFO for 1812 and later (or backported) dirs = ['META-INFO', 'etc', 'bin', 'wmake'] if '+source' in spec: dirs.extend(['applications', 'src', 'tutorials']) for d in dirs: if os.path.isdir(d): install_tree( d, join_path(self.projectdir, d), symlinks=True) dirs = ['platforms'] if '+source' in spec: dirs.extend(['doc']) # Install platforms (and doc) skipping intermediate targets relative_ignore_paths = ['src', 'applications', 'html', 'Guides'] ignore = lambda p: p in relative_ignore_paths for d in dirs: install_tree( d, join_path(self.projectdir, d), ignore=ignore, symlinks=True) etc_dir = join_path(self.projectdir, 'etc') rewrite_environ_files( # Adjust etc/bashrc and etc/cshrc edits, posix=join_path(etc_dir, 'bashrc'), cshell=join_path(etc_dir, 'cshrc')) self.install_links()
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def install_links(self): """Add symlinks into bin/, lib/ (eg, for other applications)""" # Make build log visible - it contains OpenFOAM-specific information with working_dir(self.projectdir): os.symlink( join_path(os.path.relpath(self.install_log_path)), join_path('log.' + str(self.foam_arch))) if not self.config['link']: return # ln -s platforms/linux64GccXXX/lib lib with working_dir(self.projectdir): if os.path.isdir(self.archlib): os.symlink(self.archlib, 'lib') # (cd bin && ln -s ../platforms/linux64GccXXX/bin/* .) with working_dir(join_path(self.projectdir, 'bin')): for f in [ f for f in glob.glob(join_path('..', self.archbin, "*")) if os.path.isfile(f) ]: os.symlink(f, os.path.basename(f))
def __init__(self): self.filediff = None meldsettings.connect('changed', self.on_setting_changed)
def get(self, section, option): if _section == section: if option == 'memcache_servers': if _srvs == 'error': raise NoOptionError(option, section) return _srvs elif option == 'memcache_serialization_support': if _sers == 'error': raise NoOptionError(option, section) return _sers elif option in ('memcache_max_connections', 'max_connections'): if _maxc == 'error': raise NoOptionError(option, section) return _maxc else: raise NoOptionError(option, section) else: raise NoSectionError(option)