def Current(): """ a deprecated means of specifying a preferred tag. This will return None, which is consistent with how it was typically once used as a value for a version parameter to a function. Now, passing None to version means that the version assigned with the most preferred tag is desired. """ utils.deprecated("Use of Current() is deprecated (and ignored).") return None
def deprecated_functions(): # all these functions are deprecated to_deprecate = [ ('countlink', CountLink), ('sumlink', SumLink), ('avglink', AvgLink), ('minlink', MinLink), ('maxlink', MaxLink) ] funcs = {} for name, func in to_deprecate: funcs[name] = deprecated(func, "%s(link, ...) is deprecated, please " "use link.%s(...) instead" % (name, name[:-4])) return funcs
#noinspection PyUnusedLocal def dtype(self, context): return float def make_dispatcher(agg_func, elem_func): def dispatcher(*args, **kwargs): func = agg_func if len(args) == 1 else elem_func return func(*args, **kwargs) return dispatcher functions = { 'all': All, 'any': Any, 'count': Count, 'min': make_dispatcher(Min, exprmisc.Min), 'max': make_dispatcher(Max, exprmisc.Max), 'sum': Sum, 'avg': Average, 'std': Std, 'median': Median, 'percentile': Percentile, 'gini': Gini, } for k, v in functions.items(): functions['grp' + k] = deprecated(v, "%s is deprecated, please use %s " "instead" % ('grp' + k, k))
def setup(productName, version=None, prefTags=None, productRoot=None, eupsenv=None, fwd=True, tablefile=None, exact_version=False, postTags=[]): """ Return a set of shell commands which, when sourced, will setup a product. (If fwd is false, unset it up.) Note that if the first argument is found to be an instance of Eups, this function will assume that the old setup() signature is expected by the caller, and the parameters will be forwarded to osetup(). @param productName the name of the desired product to setup. @param version the desired version of the product. This can be either a string giving an explicit version or a Tag instance. @param prefTags the list of requested tags (n.b. the VRO already knows about them) @param postTags the list of requested post-tags (n.b. the VRO already knows about them) @param productRoot the root directory where the product is installed. If set, Eups will not consult its database for the product's location, but rather set it up as a "LOCAL" product. @param eupsenv the Eups instance to use to do the setup. If None, one will be created for it. @param fwd If False, actually do an unsetup. """ if isinstance(productName, Eups): # Note: this probably won't work if a mix of key-worded and # non-keyworded parameters are used. utils.deprecated("setup(): assuming deprecated function signature", productName.quiet) if productRoot is None: productRoot = True return osetup(productName, version, prefTags, productRoot, productName.setupType) if not eupsenv: eupsenv = Eups(readCache=False, exact_version=exact_version) if version: eupsenv.selectVRO(versionName=version) if isinstance(prefTags, str): prefTags = prefTags.split() elif isinstance(prefTags, Tag): prefTags = [prefTags] if prefTags is None: prefTags = [] if postTags is None: postTags = [] if prefTags: checkTagsList(eupsenv, prefTags) if postTags: checkTagsList(eupsenv, postTags) versionRequested = version ok, version, reason = eupsenv.setup(productName, version, fwd, productRoot=productRoot, tablefile=tablefile) cmds = [] if ok: # # Check that we got the desired tag # if eupsenv.quiet <= 0 and (prefTags or postTags) and not versionRequested: taggedVersion = None for tag in prefTags: taggedVersion = eupsenv.findTaggedProduct(productName, tag) if taggedVersion: break if not taggedVersion: for tag in postTags: taggedVersion = eupsenv.findTaggedProduct(productName, tag) if taggedVersion: break if taggedVersion: if version == taggedVersion.version: # OK, we got it pass elif productRoot: # they asked for a particular directory pass else: print >> utils.stderr, "Requested version tagged %s == \"%s\"; got version \"%s\"" % \ (",".join(prefTags + postTags), taggedVersion.version, version) else: if not re.search(r"^" + Product.Product.LocalVersionPrefix, version): if (fwd and eupsenv.verbose >= 0) or (not fwd and eupsenv.verbose > 0): extra = "" if os.path.isfile((prefTags + postTags)[0]): extra = " in" print >> utils.stdwarn, "No versions of %s are tagged%s %s; setup version is %s" % \ (productName, extra, ",".join(prefTags + postTags), version) # # Set new variables # for key, val in os.environ.items(): try: if val == eupsenv.oldEnviron[key]: continue except KeyError: pass if val and not re.search(r"^['\"].*['\"]$", val) and \ re.search(r"[\s<>|&;()]", val): # quote characters that the shell cares about val = "'%s'" % val if eupsenv.shell in ("sh", "zsh",): cmd = "export %s=%s" % (key, val) elif eupsenv.shell in ("csh",): cmd = "setenv %s %s" % (key, val) if eupsenv.noaction: if eupsenv.verbose < 2 and re.search(utils.setupEnvPrefix(), key): continue # these variables are an implementation detail cmd = "echo \"%s\"" % cmd cmds += [cmd] # # unset ones that have disappeared # for key in eupsenv.oldEnviron.keys(): if re.search(r"^EUPS_(DIR|PATH)$", key): # the world will break if we delete these continue if os.environ.has_key(key): continue if eupsenv.shell == "sh" or eupsenv.shell == "zsh": cmd = "unset %s" % (key) elif eupsenv.shell == "csh": cmd = "unsetenv %s" % (key) if eupsenv.noaction: if eupsenv.verbose < 2 and re.search(utils.setupEnvPrefix(), key): continue # an implementation detail cmd = "echo \"%s\"" % cmd cmds += [cmd] # # Now handle aliases # for key in eupsenv.aliases.keys(): value = eupsenv.aliases[key] try: if value == eupsenv.oldAliases[key]: continue except KeyError: pass if eupsenv.shell == "sh": cmd = "function %s { %s ; }; export -f %s" % (key, value, key) elif eupsenv.shell == "csh": value = re.sub(r'"?\$@"?', r"\!*", value) cmd = "alias %s \'%s\'" % (key, value) elif eupsenv.shell == "zsh": cmd = "%s() { %s ; }" % (key, value, key) if eupsenv.noaction: cmd = "echo \"%s\"" % re.sub(r"`", r"\`", cmd) cmds += [cmd] # # and unset ones that used to be present, but are now gone # for key in eupsenv.oldAliases.keys(): if eupsenv.aliases.has_key(key): continue if eupsenv.shell == "sh" or eupsenv.shell == "zsh": cmd = "unset %s" % (key) elif eupsenv.shell == "csh": cmd = "unalias %s" (key) if eupsenv.noaction: cmd = "echo \"%s\"" % cmd cmds += [cmd] elif fwd and version is None: print >> utils.stderr, \ "Unable to find an acceptable version of", productName if eupsenv.verbose and os.path.exists(productName): print >> utils.stderr, "(Did you mean setup -r %s?)" % productName cmds += ["false"] # as in /bin/false else: if fwd: versionName = version if eupsenv.isLegalRelativeVersion(versionName): versionName = "" if versionName: versionName = " " + versionName print >> utils.stderr, "Failed to setup %s%s: %s" % (productName, versionName, reason) else: print >> utils.stderr, "Failed to unsetup %s: %s" % (productName, reason) cmds += ["false"] # as in /bin/false return cmds
def setup(productName, version=None, prefTags=None, productRoot=None, eupsenv=None, fwd=True, tablefile=None, exact_version=False, postTags=[]): """ Return a set of shell commands which, when sourced, will setup a product. (If fwd is false, unset it up.) Note that if the first argument is found to be an instance of Eups, this function will assume that the old setup() signature is expected by the caller, and the parameters will be forwarded to osetup(). @param productName the name of the desired product to setup. @param version the desired version of the product. This can be either a string giving an explicit version or a Tag instance. @param prefTags the list of requested tags (n.b. the VRO already knows about them) @param postTags the list of requested post-tags (n.b. the VRO already knows about them) @param productRoot the root directory where the product is installed. If set, Eups will not consult its database for the product's location, but rather set it up as a "LOCAL" product. @param eupsenv the Eups instance to use to do the setup. If None, one will be created for it. @param fwd If False, actually do an unsetup. """ if isinstance(productName, Eups): # Note: this probably won't work if a mix of key-worded and # non-keyworded parameters are used. utils.deprecated("setup(): assuming deprecated function signature", productName.quiet) if productRoot is None: productRoot = True return osetup(productName, version, prefTags, productRoot, productName.setupType) if not eupsenv: eupsenv = Eups(readCache=False, exact_version=exact_version) if version: eupsenv.selectVRO(versionName=version) if isinstance(prefTags, str): prefTags = prefTags.split() elif isinstance(prefTags, Tag): prefTags = [prefTags] if prefTags is None: prefTags = [] if postTags is None: postTags = [] if prefTags: checkTagsList(eupsenv, prefTags) if postTags: checkTagsList(eupsenv, postTags) versionRequested = version ok, version, reason = eupsenv.setup(productName, version, fwd, productRoot=productRoot, tablefile=tablefile) cmds = [] if ok: # # Check that we got the desired tag # if eupsenv.quiet <= 0 and (prefTags or postTags) and not versionRequested: taggedVersion = None for tag in prefTags: taggedVersion = eupsenv.findTaggedProduct(productName, tag) if taggedVersion: break if not taggedVersion: for tag in postTags: taggedVersion = eupsenv.findTaggedProduct(productName, tag) if taggedVersion: break if taggedVersion: if version == taggedVersion.version: # OK, we got it pass elif productRoot: # they asked for a particular directory pass else: print >> utils.stderr, "Requested version tagged %s == \"%s\"; got version \"%s\"" % \ (",".join(prefTags + postTags), taggedVersion.version, version) else: if not re.search(r"^" + Product.Product.LocalVersionPrefix, version): if (fwd and eupsenv.verbose >= 0) or (not fwd and eupsenv.verbose > 0): extra = "" if os.path.isfile((prefTags + postTags)[0]): extra = " in" print >> utils.stdwarn, "No versions of %s are tagged%s %s; setup version is %s" % \ (productName, extra, ",".join(prefTags + postTags), version) # # Set new variables # for key, val in os.environ.items(): try: if val == eupsenv.oldEnviron[key]: continue except KeyError: pass if val and not re.search(r"^['\"].*['\"]$", val) and \ re.search(r"[\s<>|&;()]", val): # quote characters that the shell cares about val = "'%s'" % val if eupsenv.shell in ( "sh", "zsh", ): cmd = "export %s=%s" % (key, val) elif eupsenv.shell in ("csh", ): cmd = "setenv %s %s" % (key, val) if eupsenv.noaction: if eupsenv.verbose < 2 and re.search(utils.setupEnvPrefix(), key): continue # these variables are an implementation detail cmd = "echo \"%s\"" % cmd cmds += [cmd] # # Extra environment variables that EUPS uses # if not fwd and productName == "eups": for k in ( "EUPS_PATH", "EUPS_PKGROOT", "EUPS_SHELL", ): if k in os.environ: del os.environ[k] # # unset ones that have disappeared # for key in eupsenv.oldEnviron.keys(): if productName != "eups": # the world will break if we delete these if re.search(r"^EUPS_(DIR|PATH|PKGROOT|SHELL)$", key): continue if os.environ.has_key(key): continue if eupsenv.shell == "sh" or eupsenv.shell == "zsh": cmd = "unset %s" % (key) elif eupsenv.shell == "csh": cmd = "unsetenv %s" % (key) if eupsenv.noaction: if eupsenv.verbose < 2 and re.search(utils.setupEnvPrefix(), key): continue # an implementation detail cmd = "echo \"%s\"" % cmd cmds += [cmd] # # Now handle aliases # for key in eupsenv.aliases.keys(): value = eupsenv.aliases[key] try: if value == eupsenv.oldAliases[key]: continue except KeyError: pass if eupsenv.shell == "sh": cmd = "function %s { %s ; }; export -f %s" % (key, value, key) elif eupsenv.shell == "csh": value = re.sub(r'"?\$@"?', r"\!*", value) cmd = "alias %s \'%s\'" % (key, value) elif eupsenv.shell == "zsh": cmd = "%s() { %s ; }" % (key, value, key) if eupsenv.noaction: cmd = "echo \"%s\"" % re.sub(r"`", r"\`", cmd) cmds += [cmd] # # and unset ones that used to be present, but are now gone # for key in eupsenv.oldAliases.keys(): if eupsenv.aliases.has_key(key): continue if eupsenv.shell == "sh" or eupsenv.shell == "zsh": cmd = "unset %s" % (key) elif eupsenv.shell == "csh": cmd = "unalias %s" (key) if eupsenv.noaction: cmd = "echo \"%s\"" % cmd cmds += [cmd] elif fwd and version is None: print >> utils.stderr, \ "Unable to find an acceptable version of", productName if eupsenv.verbose and os.path.exists(productName): print >> utils.stderr, "(Did you mean setup -r %s?)" % productName cmds += ["false"] # as in /bin/false else: if fwd: versionName = version if eupsenv.isLegalRelativeVersion(versionName): versionName = "" if versionName: versionName = " " + versionName print >> utils.stderr, "Failed to setup %s%s: %s" % ( productName, versionName, reason) else: print >> utils.stderr, "Failed to unsetup %s: %s" % (productName, reason) cmds += ["false"] # as in /bin/false return cmds