How to use the packaging.version.parse function in packaging

To help you get started, we’ve selected a few packaging examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DataDog / integrations-core / tasks / release.py View on Github external
Example invocation:
        inv release-prepare redisdb 3.1.1
    """
    # sanity check on the target
    if target not in AGENT_BASED_INTEGRATIONS:
        raise Exit("Provided target is not an Agent-based Integration")

    # don't run the task on the master branch
    if get_current_branch(ctx) == 'master':
        raise Exit("This task will add a commit, you don't want to add it on master directly")

    # sanity check on the version provided
    cur_version = get_version_string(target)
    p_version = version.parse(new_version)
    p_current = version.parse(cur_version)
    if p_version <= p_current:
        raise Exit("Current version is {}, can't bump to {}".format(p_current, p_version))

    # update the version number
    print("Current version of check {}: {}, bumping to: {}".format(target, p_current, p_version))
    update_version_module(target, cur_version, new_version)

    # update the CHANGELOG
    print("Updating the changelog")
    do_update_changelog(ctx, target, cur_version, new_version)

    # update the global requirements file
    req_file = os.path.join(ROOT, AGENT_REQ_FILE)
    print("Updating the requirements file {}".format(req_file))
    update_requirements(req_file, target, get_requirement_line(target, new_version))
github abrignoni / iLEAPP / scripts / artifacts / knowCbluetooth.py View on Github external
def get_knowCbluetooth(files_found, report_folder, seeker):
	iOSversion = scripts.artifacts.artGlobals.versionf
	if version.parse(iOSversion) < version.parse("11"):
		logfunc("Unsupported version for KnowledgC Bluetooth" + iOSversion)
		return ()

	file_found = str(files_found[0])
	db = sqlite3.connect(file_found)
	cursor = db.cursor()

	cursor.execute(
	"""
	SELECT
		DATETIME(ZOBJECT.ZSTARTDATE+978307200,'UNIXEPOCH') AS "START", 
		DATETIME(ZOBJECT.ZENDDATE+978307200,'UNIXEPOCH') AS "END",
		ZSTRUCTUREDMETADATA.Z_DKBLUETOOTHMETADATAKEY__ADDRESS AS "BLUETOOTH ADDRESS", 
		ZSTRUCTUREDMETADATA.Z_DKBLUETOOTHMETADATAKEY__NAME AS "BLUETOOTH NAME",
		(ZOBJECT.ZENDDATE - ZOBJECT.ZSTARTDATE) AS "USAGE IN SECONDS",
		(ZOBJECT.ZENDDATE - ZOBJECT.ZSTARTDATE)/60.00 AS "USAGE IN MINUTES",  
github sekipaolo / pypingdom / pypingdom / api.py View on Github external
def __init__(self, username, password, apikey, email=False, apiversion="2.0"):
        self.base_url = "https://api.pingdom.com/api/" + apiversion + "/"
        if version.parse(apiversion) < version.parse('3.0'):
            self.auth = HTTPBasicAuth(username, password)
            self.headers = {'App-Key': apikey}
            if email:
                self.headers['Account-Email'] = email
        else:
            self.headers = {'Authorization': 'Bearer ' + apikey}
            self.auth = None
github fastai / fastai / fastai / utils / collect_env.py View on Github external
def check_perf():
    "Suggest how to improve the setup to speed things up"

    from PIL import features, Image
    from packaging import version
    import pynvml

    print("Running performance checks.")

    # libjpeg_turbo check
    print("\n*** libjpeg-turbo status")
    if version.parse(Image.PILLOW_VERSION) >= version.parse("5.4.0"):
        if features.check_feature('libjpeg_turbo'):
            print("✔ libjpeg-turbo is on")
        else:
            print("✘ libjpeg-turbo is not on. It's recommended you install libjpeg-turbo to speed up JPEG decoding. See https://docs.fast.ai/performance.html#libjpeg-turbo")
    else:
        print(f"❓ libjpeg-turbo's status can't be derived - need Pillow(-SIMD)? >= 5.4.0 to tell, current version {Image.PILLOW_VERSION}")
        # XXX: remove this check/note once Pillow and Pillow-SIMD 5.4.0 is available
        pillow_ver_5_4_is_avail = pypi_module_version_is_available("Pillow", "5.4.0")
        if pillow_ver_5_4_is_avail == False:
            print("5.4.0 is not yet available, other than the dev version on github, which can be installed via pip from git+https://github.com/python-pillow/Pillow. See https://docs.fast.ai/performance.html#libjpeg-turbo")

    # Pillow-SIMD check
    print("\n*** Pillow-SIMD status")
    if re.search(r'\.post\d+', Image.PILLOW_VERSION):
        print(f"✔ Running Pillow-SIMD {Image.PILLOW_VERSION}")
    else:
github ryantam626 / jupyterlab_code_formatter / serverextension / jupyterlab_code_formatter / formatters.py View on Github external
def handle_options(**options):
        import black

        file_mode_change_version = version.parse("19.3b0")
        current_black_version = version.parse(black.__version__)
        if current_black_version >= file_mode_change_version:
            return {"mode": black.FileMode(**options)}
        else:
            return options
github e2nIEE / pandapower / pandapower / toolbox.py View on Github external
OUTPUT:
      No output; the net passed as input has pandapower-default dtypes of columns in element tables.

    """
    new_net = create_empty_network()
    for key, item in net.items():
        if isinstance(item, pd.DataFrame):
            for col in item.columns:
                if key in new_net and col in new_net[key].columns:
                    if set(item.columns) == set(new_net[key]):
                        if version.parse(pd.__version__) < version.parse("0.21"):
                            net[key] = net[key].reindex_axis(new_net[key].columns, axis=1)
                        else:
                            net[key] = net[key].reindex(new_net[key].columns, axis=1)
                    if version.parse(pd.__version__) < version.parse("0.20.0"):
                        net[key][col] = net[key][col].astype(new_net[key][col].dtype,
                                                             raise_on_error=False)
                    else:
                        net[key][col] = net[key][col].astype(new_net[key][col].dtype,
                                                             errors="ignore")
github jheling / freeathome / freeathome / get-master-message.py View on Github external
async def start(self, event):
        log.debug("begin session start")

        if version.parse(self.fahversion) >= version.parse("2.3.0"):
            await self.saslhandler.initiate_key_exchange()  

        await self.presence_and_roster()

        await self.rpc()
github abrignoni / iLEAPP / scripts / artifacts / knowCall.py View on Github external
ON ZOBJECT.ZSTRUCTUREDMETADATA = ZSTRUCTUREDMETADATA.Z_PK 
			LEFT JOIN
				ZSOURCE 
				ON ZOBJECT.ZSOURCE = ZSOURCE.Z_PK 
		WHERE
			ZSTREAMNAME is "/display/isBacklit"
		""")
	else:
		logfunc("Unsupported version for KnowledgC Backlit" + iOSversion)
		return ()
	
	all_rows = cursor.fetchall()
	usageentries = len(all_rows)
	if usageentries > 0:
		data_list = []
		if version.parse(iOSversion) >= version.parse("12"):	
			for row in all_rows:    
				data_list.append((row[0],row[1],row[2],row[3],row[4],row[5],row[6],row[7],row[8],row[9],row[10]))

			report = ArtifactHtmlReport('KnowledgeC Device is Backlit')
			report.start_artifact_report(report_folder, 'Device is Backlit')
			report.add_script()
			data_headers = ('Start','End','Screen is Backlit','Usage in Seconds','Usage in Minutes','Hardware UUID','Day of Week','GMT Offset','Entry Creation','UUID','ZOBJECT Table ID')  
			report.write_artifact_data_table(data_headers, data_list, file_found)
			report.end_artifact_report()
			
			tsvname = 'KnowledgeC Device is Backlit'
			tsv(report_folder, data_headers, data_list, tsvname)
			
			tlactivity = 'KnowledgeC Device is Backlit'
			timeline(report_folder, tlactivity, data_list)
github errantlinguist / tangrams-restricted / analysis / scripts / write_target_ref_utts.py View on Github external
result = len(ordering)
	return result


def __reindex_cols_old_api(df: pd.DataFrame, partial_ordering: Sequence[str]) -> pd.DataFrame:
	return df.reindex_axis(sorted(df.columns, key=lambda col_name: __element_order(col_name, partial_ordering)), axis=1,
						   copy=False)


def __reindex_cols_new_api(df: pd.DataFrame, partial_ordering: Sequence[str]) -> pd.DataFrame:
	return df.reindex(sorted(df.columns, key=lambda col_name: __element_order(col_name, partial_ordering)), axis=1,
					  copy=False)


__PANDAS_API_BREAKING_VERSION = "0.21.0"
if packaging.version.parse(pd.__version__) < packaging.version.parse(__PANDAS_API_BREAKING_VERSION):
	logging.warning("Version of installed pandas (\"%s\") is older than expected (\"%s\").", pd.__version__,
					__PANDAS_API_BREAKING_VERSION)
	__reindex_cols = __reindex_cols_old_api
else:
	__reindex_cols = __reindex_cols_new_api


def __create_argparser() -> argparse.ArgumentParser:
	result = argparse.ArgumentParser(
		description="Reads in event and utterance files for a directory of sessions and prints the utterance information alongside the target referent entity information on the same row to the standard output stream.")
	result.add_argument("inpaths", metavar="INPATH", nargs='+',
						help="The paths to search for sessions to process.")
	return result


def __main(args):
github datawire / ambassador / python / kat / harness.py View on Github external
def is_knative():
    # Skip KNative immediately for run_mode local.
    if RUN_MODE == 'local':
        return False

    is_cluster_compatible = True
    kube_json = kube_version_json()

    server_version = kube_server_version(kube_json)
    client_version = kube_client_version(kube_json)

    if server_version:
        if version.parse(server_version) < version.parse('1.11'):
            print(f"server version {server_version} is incompatible with Knative")
            is_cluster_compatible = False
        else:
            print(f"server version {server_version} is compatible with Knative")
    else:
        print("could not determine Kubernetes server version?")

    if client_version:
        if version.parse(client_version) < version.parse('1.10'):
            print(f"client version {client_version} is incompatible with Knative")
            is_cluster_compatible = False
        else:
            print(f"client version {client_version} is compatible with Knative")
    else:
        print("could not determine Kubernetes client version?")