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

Test code boilerplate stuff #25

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
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
16 changes: 0 additions & 16 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,6 @@ about: Report a reproducible bug in the current release of Phabfive
3.


### Schema

<!-- Update me -->
```

```


### Data

<!-- Update me -->
```

```


<!-- What did you expect to happen? -->
### Expected Behavior

Expand Down
11 changes: 8 additions & 3 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ about: Propose a new Phabfive feature or enhancement
-->

### Environment
* Phabfive version: <!-- Example: 1.7.0 -->
* Python version: <!-- Example: 3.7.0 -->
<!-- Example: 1.7.0 -->
* Phabfive version:

<!-- Example: 3.7.0 -->
* Python version:

<!--
Describe in detail the new functionality you are proposing. Include any
Expand All @@ -32,7 +35,9 @@ about: Propose a new Phabfive feature or enhancement
-->
### Use Case

* None


### Other?

None
* None
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,6 @@ bdist: ## build a wheel distribution

install: ## install package
python setup.py install

mkdocs-dev:
mkdocs serve
36 changes: 12 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,18 @@
# phabfive

A command line tool to interact with Phabricator.

The complete documentation for Phabfive can be found at [Read the Docs](https://phabfive.readthedocs.io/en/latest/)

[![Travis CI](https://travis-ci.com/dynamist/phabfive.svg?branch=master)](https://travis-ci.com/dynamist/phabfive)
[![Current release](https://img.shields.io/github/v/release/dynamist/phabfive.svg)](https://github.com/dynamist/phabfive/releases)
[![GitHub issues](https://img.shields.io/github/issues/dynamist/phabfive.svg?maxAge=360)](https://github.com/dynamist/phabfive/issues)
[![License](https://img.shields.io/github/license/dynamist/phabfive?color=%23fe0000)](https://github.com/dynamist/phabfive/blob/master/LICENSE)
[![Python2](https://img.shields.io/badge/python2-2.7-blue.svg)](https://github.com/dynamist/phabfive/)
[![Python3](https://img.shields.io/badge/python3-3.6,3.7,3.8-blue.svg)](https://github.com/dynamist/phabfive/)

## Features

A summary of the currently supported actions, as well as planned features:
A command line tool to interact with Phabricator.

- Passphrase
- [X] Get specified secret
- Diffusion
- [X] List repositories names
- [X] Get branches for specified repository
- [X] Get clone URI:s for specified repository
- [X] Add repository
- [X] Edit URI
- [X] Observe repositories: create uri
- Paste
- [X] List pastes
- [X] Get specified paste
- [X] Add paste
- User
- [X] Who am I: information about the logged-in user
The complete documentation and detailed documentation of all implemented commands for Phabfive can be found at [Read the Docs](https://phabfive.readthedocs.io/en/latest/)


## Example usage
## Basic example

Grab a Phabricator token at https://<yourserver.com>/settings/panel/apitokens/

Expand All @@ -40,9 +26,11 @@ Usage:

phabfive passphrase K123

More detailed examples can be found on the [Read the Docs](https://phabfive.readthedocs.io/en/latest/) website


## LICENSE

Copyright (c) 2017-2019 Dynamist AB
Copyright (c) 2017-2020 Dynamist AB

See the LICENSE file provided with the source distribution for full details.
11 changes: 11 additions & 0 deletions docs/modules/diffusion.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Module Diffusion


## Impelmented commands

- List repositories names
- Get branches for specified repository
- Get clone URI:s for specified repository
- Add repository
- Edit URI
- Observe repositories: create uri
6 changes: 6 additions & 0 deletions docs/modules/passphrase.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Module Passphrase


## Impelmented commands

- Get specified secret
8 changes: 8 additions & 0 deletions docs/modules/paste.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Module Paste


## Impelmented commands

- List pastes
- Get specified paste
- Add paste
6 changes: 6 additions & 0 deletions docs/modules/user.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Module User


## Impelmented commands

- Who am I: information about the logged-in user
5 changes: 5 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ repo_url: https://github.com/dynamist/phabfive
nav:
- Introduction: 'index.md'
- Development: 'development.md'
- Modules:
- Diffusion: 'modules/diffusion.md'
- Passphrase: 'modules/passphrase.md'
- Paste: 'modules/paste.md'
- User: 'modules/user.md'

markdown_extensions:
- admonition:
2 changes: 1 addition & 1 deletion phabfive/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

# phabfive imports
from phabfive import passphrase, diffusion, paste, user
from phabfive.constants import MONOGRAMS, REPO_STATUS_CHOICES
from phabfive.constants import *
from phabfive.exceptions import (
PhabfiveConfigException,
PhabfiveDataException,
Expand Down
18 changes: 9 additions & 9 deletions phabfive/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,23 @@

class Phabfive(object):
def __init__(self):

# Get super-early debugging by `export PHABFIVE_DEBUG=1`
if "PHABFIVE_DEBUG" in os.environ:
log.setLevel(logging.DEBUG)
log.info(
"Loglevel is: {}".format(logging.getLevelName(log.getEffectiveLevel()))
"Loglevel is: {0}".format(logging.getLevelName(log.getEffectiveLevel()))
)

self.conf = self.load_config()

maxlen = 8 + len(max(dict(self.conf).keys(), key=len))
for k, v in dict(self.conf).items():
log.debug("{} {} {}".format(k, "." * (maxlen - len(k)), v))
log.debug("{0} {1} {2}".format(k, "." * (maxlen - len(k)), v))

# check for required configurables
for k, v in dict(self.conf).items():
if k in REQUIRED and not v:
error = "{} is not configured".format(k)
error = "{0} is not configured".format(k)
example = CONFIG_EXAMPLES.get(k)
if example:
error += ", " + example
Expand All @@ -65,11 +64,12 @@ def __init__(self):
# check validity of configurables
for k in VALIDATORS.keys():
if not re.match(VALIDATORS[k], self.conf[k]):
error = "{} is malformed".format(k)
error = "{0} is malformed".format(k)
example = VALID_EXAMPLES.get(k)
if example:
error += ", " + example
raise PhabfiveConfigException(error)

self.phab = Phabricator(
host=self.conf.get("PHAB_URL"), token=self.conf.get("PHAB_TOKEN")
)
Expand Down Expand Up @@ -105,7 +105,7 @@ def load_config(self):
os.environ["XDG_CONFIG_DIRS"] = "/etc"

site_conf_file = os.path.join(appdirs.site_config_dir("phabfive") + ".yaml")
log.debug("Loading configuration file: {}".format(site_conf_file))
log.debug("Loading configuration file: {0}".format(site_conf_file))
anyconfig.merge(
conf,
{
Expand All @@ -120,7 +120,7 @@ def load_config(self):
site_conf_dir = os.path.join(
appdirs.site_config_dir("phabfive") + ".d", "*.yaml"
)
log.debug("Loading configuration files: {}".format(site_conf_dir))
log.debug("Loading configuration files: {0}".format(site_conf_dir))
anyconfig.merge(
conf,
{
Expand All @@ -131,7 +131,7 @@ def load_config(self):
)

user_conf_file = os.path.join(appdirs.user_config_dir("phabfive")) + ".yaml"
log.debug("Loading configuration file: {}".format(user_conf_file))
log.debug("Loading configuration file: {0}".format(user_conf_file))
anyconfig.merge(
conf,
{
Expand All @@ -146,7 +146,7 @@ def load_config(self):
user_conf_dir = os.path.join(
appdirs.user_config_dir("phabfive") + ".d", "*.yaml"
)
log.debug("Loading configuration files: {}".format(user_conf_dir))
log.debug("Loading configuration files: {0}".format(user_conf_dir))
anyconfig.merge(
conf,
{
Expand Down
7 changes: 1 addition & 6 deletions phabfive/diffusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@
import re

# phabfive imports
from phabfive.constants import (
DISPLAY_CHOICES,
IO_NEW_URI_CHOICES,
MONOGRAMS,
REPO_STATUS_CHOICES,
)
from phabfive.constants import *
from phabfive.core import Phabfive
from phabfive.exceptions import PhabfiveDataException, PhabfiveConfigException
from phabfive import passphrase
Expand Down
2 changes: 1 addition & 1 deletion phabfive/passphrase.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

# phabfive imports
from phabfive.core import Phabfive
from phabfive.constants import MONOGRAMS
from phabfive.constants import *
from phabfive.exceptions import PhabfiveDataException, PhabfiveRemoteException

# 3rd party imports
Expand Down
13 changes: 9 additions & 4 deletions phabfive/paste.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# phabfive imports
from phabfive.core import Phabfive
from phabfive.exceptions import PhabfiveDataException
from phabfive.constants import MONOGRAMS
from phabfive.constants import *

# 3rd party imports
from phabricator import APIError
Expand All @@ -21,6 +21,9 @@ def _validate_identifier(self, id_):

def _convert_ids(self, ids):
"""Method used by print function."""
if not isinstance(ids, list):
raise PhabfiveDataException("variable ids must be of list type")

ids_list_int = []

for id_ in ids:
Expand Down Expand Up @@ -48,12 +51,14 @@ def create_paste(

:rtype: dict
"""
text = None
tags = tags if tags else []
subscribers = subscribers if subscribers else []

with open(file, "r") as f:
text = f.read()
if file:
with open(file, "r") as f:
text = f.read()
else:
text = None

transactions = []
transactions_values = [
Expand Down
10 changes: 5 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
CHANGELOG = f.read()

install_requires = ["anyconfig", "appdirs", "phabricator", "pyyaml", "docopt"]
tests_require = ["coverage", "flake8", "pytest", "tox"]
docs_require = ["docs"]
download_url = "{}/tarball/v{}".format(
tests_require = ["coverage", "flake8", "pytest", "tox", "mock"]
docs_require = ["mkdocs"]
download_url = "{0}/tarball/v{1}".format(
"https://github.com/dynamist/phabfive", phabfive.__version__
)

Expand All @@ -41,7 +41,7 @@
extras_require={"test": tests_require, "docs": docs_require},
packages=["phabfive"],
entry_points={"console_scripts": ["phabfive = phabfive.cli:cli_entrypoint"]},
python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*",
python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*",
classifiers=[
# 'Development Status :: 1 - Planning',
# "Development Status :: 2 - Pre-Alpha",
Expand All @@ -56,9 +56,9 @@
"Environment :: Console",
"Programming Language :: Python",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"License :: OSI Approved :: Apache Software License",
"Natural Language :: English",
],
Expand Down
Loading