Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Python 2.7 #64

Merged
merged 1 commit into from
Jan 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
repos:
- repo: https://github.com/pre-commit/mirrors-autopep8
rev: v1.4.4
rev: v1.5
hooks:
- id: autopep8
- repo: git://github.com/pre-commit/pre-commit-hooks
rev: v2.2.3
rev: v2.4.0
hooks:
- id: fix-encoding-pragma
- id: trailing-whitespace
Expand Down Expand Up @@ -49,7 +49,7 @@ repos:
language: system
types: [python]
- repo: git://github.com/Lucas-C/pre-commit-hooks
rev: v1.1.6
rev: v1.1.7
hooks:
- id: remove-tabs
- id: remove-crlf
52 changes: 11 additions & 41 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,48 +1,34 @@
sudo: required
dist: xenial
dist: bionic
language: python
python: 3.6
services:
- postgresql
- redis-server
language: python
stages:
- lint
- test
- test-docker
- deploy
cache: pip
".before_install": &3
before_install:
- bash -xe travis/before-install.sh
".install": &1
install:
- pip install -r requirements-dev.txt
".script": &4
script:
- bash -xe travis/unit-tests.sh
- bash -xe travis/test-deploy.sh
".lint_script": &2
- pre-commit run -a
- radon cc pacifica
jobs:
include:
- stage: lint
services: []
python: 3.6
install: *1
script: *2
- python: 2.7
services: []
script: *2
install: *1
before_install: skip
script:
- pre-commit run -a
- radon cc pacifica
- stage: test
python: 2.7
before_install: *3
install: *1
script: *4
- python: 3.6
before_install: *3
install: *1
script: *4
- stage: test-docker
before_install: skip
sudo: required
python: 3.6
services:
- docker
script:
Expand All @@ -67,10 +53,8 @@ jobs:
docker run -t --rm --network=pacifica-cli_default pacifica/cli download --transaction-id 1 --destination /tmp/foo;
- stage: deploy
services: []
language: python
before_install: skip
script: skip
python: 3.6
deploy:
skip_cleanup: true
provider: pypi
Expand All @@ -80,17 +64,3 @@ jobs:
secure: AN8nG/iEsZ1Ol+WZyfkf9H0uFYAmU+H04j6chHHFBqWVFZcbITXa6m0KjKXg/gcGcJz4RnEwKD6qBwb8YMBDODmkmah88VgsXR+hiAJlq4cTYMEMrEewnRZ9fH3f0BCle8FSI16VeHDYOdYvMGRDJXKIn/GxNc6xNVgwEcKqf5tBOt6C+LzemlYHVbx+KBQR9kRaRJOcnLnvVS50gCamQ7YIRyBRNDFyE3luLIm5VDGPO11E9be2OrXCrpSf1fPftiqYyzpT8ttLt+0Rar5J69EC65U/ZVtiJ96Y36FNCVpj9NL+UokcLrdnlU4lSsbqttwDNskSCA6CQ1FCMjTZAgJAI/gTUv2gL3NTzGnAQtcKL8KUeMU37Au5MP4BxfMDofUvxNRdScODWyNRU1fWGmj+e22nAx+gODpiTntR+rm8LR16f+CBs0D8VT371bHjUYXu6H2mDH1lJPISGaG5gEoTH0FpVEoOg82dQAy4IikLA09ra2USaXgV4leuXcBHyxmAZTxhP1YIWXszx1XUa1DP3hqkvqecNU1QuQnG5subHan482tDNY61MDgF9o010h/CgqDU1Tui5ozyHYPjHSaErzYeXF8LUTk8f0NiOkERetzCF0vFX+ZKBvjEMwkjozMPNXZvdjJdrTb90p9dxt8/NdWtZ97jSpItoDTAxSo=
on:
tags: true
- services: []
language: python
before_install: skip
script: skip
python: 2.7
deploy:
skip_cleanup: true
provider: pypi
user: dmlb2000
distributions: bdist_wheel
password:
secure: AN8nG/iEsZ1Ol+WZyfkf9H0uFYAmU+H04j6chHHFBqWVFZcbITXa6m0KjKXg/gcGcJz4RnEwKD6qBwb8YMBDODmkmah88VgsXR+hiAJlq4cTYMEMrEewnRZ9fH3f0BCle8FSI16VeHDYOdYvMGRDJXKIn/GxNc6xNVgwEcKqf5tBOt6C+LzemlYHVbx+KBQR9kRaRJOcnLnvVS50gCamQ7YIRyBRNDFyE3luLIm5VDGPO11E9be2OrXCrpSf1fPftiqYyzpT8ttLt+0Rar5J69EC65U/ZVtiJ96Y36FNCVpj9NL+UokcLrdnlU4lSsbqttwDNskSCA6CQ1FCMjTZAgJAI/gTUv2gL3NTzGnAQtcKL8KUeMU37Au5MP4BxfMDofUvxNRdScODWyNRU1fWGmj+e22nAx+gODpiTntR+rm8LR16f+CBs0D8VT371bHjUYXu6H2mDH1lJPISGaG5gEoTH0FpVEoOg82dQAy4IikLA09ra2USaXgV4leuXcBHyxmAZTxhP1YIWXszx1XUa1DP3hqkvqecNU1QuQnG5subHan482tDNY61MDgF9o010h/CgqDU1Tui5ozyHYPjHSaErzYeXF8LUTk8f0NiOkERetzCF0vFX+ZKBvjEMwkjozMPNXZvdjJdrTb90p9dxt8/NdWtZ97jSpItoDTAxSo=
on:
tags: true
1 change: 0 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ environment:
BACKEND_URL: redis://127.0.0.1:6379/0

matrix:
- PYTHON: C:\Python27-x64
- PYTHON: C:\Python36-x64

services:
Expand Down
5 changes: 4 additions & 1 deletion pacifica/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""Pacifica Namespace."""
__import__('pkg_resources').declare_namespace(__name__)
try:
__import__('pkg_resources').declare_namespace(__name__)
except ImportError:
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
36 changes: 13 additions & 23 deletions pacifica/cli/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from sys import stdin, stdout, stderr
from subprocess import Popen, PIPE
from os import getenv, pathsep, path
from functools import cmp_to_key
import re
from six import text_type, PY2


def set_query_obj(dep_meta_ids, md_update, obj):
Expand Down Expand Up @@ -40,16 +40,11 @@ def id_cmp(a_id, b_id):
int_a = int(num_re.match(a_id).group(0))
int_b = int(num_re.match(b_id).group(0))
return int_a < int_b
yield text_type("""
yield """
{} - Select an ID
=====================================
""").format(title)
if PY2: # pragma: no cover python 2 only
sort_args = {'cmp': id_cmp}
else: # pragma: no cover python 3+ only
from functools import cmp_to_key
sort_args = {'key': cmp_to_key(id_cmp)}
for _id in sorted(valid_ids, **sort_args):
""".format(title)
for _id in sorted(valid_ids, key=cmp_to_key(id_cmp)):
yield display_data[_id]


Expand All @@ -58,17 +53,16 @@ def format_query_results(md_update, query_obj):
valid_ids = []
display_data = {}
for obj in md_update[query_obj.metaID].query_results:
valid_ids.append(text_type(obj[query_obj.valueField]))
display_data[text_type(
obj[query_obj.valueField])] = md_update[query_obj.metaID].displayFormat.format(**obj)
valid_ids.append(str(obj[query_obj.valueField]))
display_data[str(obj[query_obj.valueField])] = md_update[query_obj.metaID].displayFormat.format(**obj)
return (valid_ids, display_data)


def set_selected_id(selected_id, default_id, valid_ids):
"""Return the selected ID validating it first."""
if not selected_id:
selected_id = default_id
if text_type(selected_id) not in valid_ids:
if str(selected_id) not in valid_ids:
selected_id = False
return selected_id

Expand Down Expand Up @@ -110,7 +104,7 @@ def execute_pager(content):
stdout=stdout,
stderr=stderr
)
pager_proc.communicate(text_type('\n').join(content).encode('utf-8'))
pager_proc.communicate('\n'.join(content).encode('utf-8'))
return pager_proc.wait()


Expand All @@ -123,7 +117,7 @@ def interactive_select_loop(md_update, query_obj, default_id):
while not selected_id:
execute_pager(paged_content(
query_obj.displayTitle, display_data, valid_ids))
stdout.write(text_type('Select ID ({}): ').format(default_id))
stdout.write('Select ID ({}): '.format(default_id))
selected_id = stdin.readline().strip()
selected_id = set_selected_id(selected_id, default_id, valid_ids)
return selected_id
Expand All @@ -134,10 +128,7 @@ def set_results(md_update, query_obj, default_id, interactive=False):
if interactive:
selected_id = interactive_select_loop(md_update, query_obj, default_id)
else:
print_text = text_type('Setting {} to {}.').format(
query_obj.metaID, default_id)
if PY2: # pragma: no cover python 2 only
print_text = print_text.encode('utf8')
print_text = 'Setting {} to {}.'.format(query_obj.metaID, default_id)
print(print_text)
selected_id = default_id
if selected_id != md_update[query_obj.metaID].value:
Expand All @@ -152,7 +143,7 @@ def filter_results(md_update, query_obj, regex):
filtered_results = []
for index in range(len(query_obj.query_results)):
res = query_obj.query_results[index]
if reg_engine.search(display_data[text_type(res[query_obj.valueField])]):
if reg_engine.search(display_data[str(res[query_obj.valueField])]):
filtered_results.append(query_obj.query_results[index])
md_update[query_obj.metaID] = query_obj._replace(
query_results=filtered_results)
Expand All @@ -177,7 +168,7 @@ def query_main(md_update, args):
query_obj = find_leaf_node(md_update)
regex = getattr(args, '{}_regex'.format(query_obj.metaID))
if not regex:
regex = text_type('.*')
regex = '.*'
filter_results(md_update, query_obj, regex)
default_id = getattr(args, query_obj.metaID, None)
if not default_id:
Expand All @@ -189,7 +180,6 @@ def query_main(md_update, args):
args.interactive
)
if not md_update[query_obj.metaID].value:
raise RuntimeError(
text_type('Could not find value for {}').format(query_obj.metaID))
raise RuntimeError('Could not find value for {}'.format(query_obj.metaID))
remove_results(md_update)
return md_update
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pacifica-downloader
pacifica-namespace
pacifica-uploader
pager
six
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
description='Pacifica CLI Tool',
author='David Brown',
author_email='david.brown@pnnl.gov',
url='https://pypi.python.org/pypi/pacifica-cli/',
url='https://github.com/pacifica/pacifica-cli/',
long_description=open(path.join(
path.abspath(path.dirname(__file__)),
'README.md')).read(),
long_description_content_type='text/markdown',
packages=find_packages(),
packages=find_packages(include=['pacifica.*']),
namespace_packages=['pacifica'],
entry_points={
'console_scripts': ['pacifica-cli=pacifica.cli.__main__:main'],
Expand Down