diff options
-rw-r--r-- | pbr/cmd/main.py | 9 | ||||
-rw-r--r-- | pbr/hooks/files.py | 7 | ||||
-rw-r--r-- | pbr/util.py | 18 | ||||
-rw-r--r-- | releasenotes/notes/cmd-e6664dcbd42d3935.yaml | 11 | ||||
-rw-r--r-- | tools/integration.sh | 2 |
5 files changed, 40 insertions, 7 deletions
diff --git a/pbr/cmd/main.py b/pbr/cmd/main.py index 91ea384..162304f 100644 --- a/pbr/cmd/main.py +++ b/pbr/cmd/main.py @@ -40,8 +40,11 @@ def get_sha(args): def get_info(args): - print("{name}\t{version}\t{released}\t{sha}".format( - **_get_info(args.name))) + if args.short: + print("{version}".format(**_get_info(args.name))) + else: + print("{name}\t{version}\t{released}\t{sha}".format( + **_get_info(args.name))) def _get_info(name): @@ -98,6 +101,8 @@ def main(): 'info', help='print version info for package') cmd_info.set_defaults(func=get_info) cmd_info.add_argument('name', help='package to print info of') + cmd_info.add_argument('-s', '--short', action="store_true", + help='only display package version') cmd_freeze = subparsers.add_parser( 'freeze', help='print version info for all installed packages') diff --git a/pbr/hooks/files.py b/pbr/hooks/files.py index 0fe0df5..c44af7c 100644 --- a/pbr/hooks/files.py +++ b/pbr/hooks/files.py @@ -41,6 +41,13 @@ def unquote_path(path): # strip the quotes off individual path components because os.walk cannot # handle paths like: "'i like spaces'/'another dir'", so we will pass it # "i like spaces/another dir" instead. + + if os.name == 'nt': + # shlex cannot handle paths that contain backslashes, treating those + # as escape characters. + path = path.replace("\\", "/") + return "".join(shlex.split(path)).replace("/", "\\") + return "".join(shlex.split(path)) diff --git a/pbr/util.py b/pbr/util.py index 323747e..6b2e87d 100644 --- a/pbr/util.py +++ b/pbr/util.py @@ -162,6 +162,16 @@ BOOL_FIELDS = ("use_2to3", "zip_safe", "include_package_data") CSV_FIELDS = () +def shlex_split(path): + if os.name == 'nt': + # shlex cannot handle paths that contain backslashes, treating those + # as escape characters. + path = path.replace("\\", "/") + return [x.replace("/", "\\") for x in shlex.split(path)] + + return shlex.split(path) + + def resolve_name(name): """Resolve a name like ``module.object`` to an object and return it. @@ -374,22 +384,22 @@ def setup_cfg_to_setup_kwargs(config, script_args=()): for line in in_cfg_value: if '=' in line: key, value = line.split('=', 1) - key_unquoted = shlex.split(key.strip())[0] + key_unquoted = shlex_split(key.strip())[0] key, value = (key_unquoted, value.strip()) if key in data_files: # Multiple duplicates of the same package name; # this is for backwards compatibility of the old # format prior to d2to1 0.2.6. prev = data_files[key] - prev.extend(shlex.split(value)) + prev.extend(shlex_split(value)) else: - prev = data_files[key.strip()] = shlex.split(value) + prev = data_files[key.strip()] = shlex_split(value) elif firstline: raise errors.DistutilsOptionError( 'malformed package_data first line %r (misses ' '"=")' % line) else: - prev.extend(shlex.split(line.strip())) + prev.extend(shlex_split(line.strip())) firstline = False if arg == 'data_files': # the data_files value is a pointlessly different structure diff --git a/releasenotes/notes/cmd-e6664dcbd42d3935.yaml b/releasenotes/notes/cmd-e6664dcbd42d3935.yaml new file mode 100644 index 0000000..c5cf096 --- /dev/null +++ b/releasenotes/notes/cmd-e6664dcbd42d3935.yaml @@ -0,0 +1,11 @@ +--- +features: + - | + Add an option to print only the version of a package + + Example: + + .. code-block:: bash + + $ pbr info -s pkgname + 1.2.3 diff --git a/tools/integration.sh b/tools/integration.sh index 3b431e1..6c4dc16 100644 --- a/tools/integration.sh +++ b/tools/integration.sh @@ -30,7 +30,7 @@ REPODIR=${REPODIR:-$BASE/new} # TODO: Figure out how to get this on to the box properly sudo apt-get update -sudo apt-get install -y --force-yes libvirt-dev libxml2-dev libxslt-dev libmysqlclient-dev libpq-dev libnspr4-dev pkg-config libsqlite3-dev libffi-dev libldap2-dev libsasl2-dev ccache libkrb5-dev liberasurecode-dev libjpeg-dev +sudo apt-get install -y --force-yes libvirt-dev libxml2-dev libxslt-dev libmysqlclient-dev libpq-dev libnspr4-dev pkg-config libsqlite3-dev libffi-dev libldap2-dev libsasl2-dev ccache libkrb5-dev liberasurecode-dev libjpeg-dev libsystemd-dev libnss3-dev libssl-dev # FOR numpy / pyyaml # The source list has been removed from our apt config so rather than |