-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 0431030
Showing
22 changed files
with
1,087 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.* | ||
!.editorconfig | ||
!.travis* | ||
!.git* | ||
|
||
# Python | ||
/dist | ||
/build | ||
*.pyc | ||
*.pyo | ||
*.egg* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
sudo: false | ||
language: python | ||
python: | ||
- '2.7' | ||
install: | ||
- travis_retry pip install -r requirements.txt | ||
- travis_retry pip install -r test-requirements.txt | ||
before_script: pep8 --max-line-length=120 | ||
script: python setup.py test --addopts '-vv' | ||
deploy: | ||
provider: pypi | ||
user: bgaifullin | ||
password: | ||
secure: e6aJZA7Bzc45IVwZ0+Lv/Peav3QF4gFmsOW4TeZwRKZ8ElBBFs6nMW+mu7WwyhB/aGIYcaJ/mjY2/xBFy3zn4vGNpeMy7rbVrExIhRTGuYOXU+PLnorSoCj4QZGcza+k6s5a8wdDciCQWRxvxBm9ztDYolqYb+z0SqE1yRjcS1rTh+YjuYGqh2OOG0JnxQoucaJ4kBVaeoU3jvTvCx3pja8IfVN9e0nWnXDbjqpCJaBzgH0q3bbxvExflueX+EtV3/rm7Ak2kDegdy/C6IiQg69LJXPzqifgE4X+Vi12F6CLpUp5oEIawQcUq8woIK9q8Gdm8v0O2Fit1kTNaVya4wKsyYku7AJ85pLVeM12baZXEYQA+2HyHeqEFlRLw7Y2hy8hUFKNGeiKFEk7GzJI7UspQCkeW4QtgB+lyvtUOK6NQYK1RyMGlh8wQiiYlhpnE2sAerE9dh8+0FYCxSkH0wBGjOCMq8+/WkUy/pTrWzVJfM9LISkE9gPkPpQ4LXpQD9b39R55qTNOGpHlwqGY4zr3F0d2oibPLi5xFD8GQpZEiSCcYNiffkqhjb4CAaVc6zowkeIY99qqQ+Ie3KFlbJ1GW8utzxP2GDmW+YJVYI+9qWiGiiboskX05/udbof6wWd4vpaNK1kUKc+oDyTm3Q/bq2YO/Ns9n3TUvZJdvfc= | ||
on: | ||
tags: true | ||
distributions: sdist bdist_wheel | ||
repo: bgaifullin/python-jiractl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2014 Ryan Leckey | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is furnished | ||
to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
include ChangeLog | ||
|
||
include README.rst | ||
include *requirements.txt | ||
|
||
global-exclude *.pyc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
python-jiractl | ||
============== | ||
|
||
.. image:: https://travis-ci.org/bgaifullin/python-jiractl.png?branch=master | ||
:target: https://travis-ci.org/bgaifullin/python-jiractl | ||
.. image:: https://img.shields.io/pypi/v/jiractl.svg | ||
:target: https://pypi.python.org/pypi/jiractl | ||
|
||
|
||
The command line interface for Jira REST API | ||
|
||
****** | ||
Usage | ||
****** | ||
|
||
************ | ||
Requirements | ||
************ | ||
- jira>=1.0.10 | ||
- pbr>=1.6 | ||
- cliff>=1.18.0 | ||
|
||
******* | ||
Install | ||
******* | ||
|
||
Automated | ||
--------- | ||
1. **jiractl** can be installed through `easy_install` or `pip`. | ||
|
||
.. code-block:: bash | ||
pip install jiractrl | ||
Manual | ||
------ | ||
|
||
1. Clone the **xmlsec** repository to your local computer. | ||
|
||
.. code-block:: bash | ||
git clone git://github.com/bgaifullin/python-jiractrl.git | ||
2. Change into the **jiractrl** root directory. | ||
|
||
.. code-block:: bash | ||
cd /path/to/jiractrl | ||
3. Install the project and all its dependencies using `pip`. | ||
|
||
.. code-block:: bash | ||
pip install . | ||
******* | ||
License | ||
******* | ||
|
||
Unless otherwise noted, all files contained within this project are liensed under the MIT opensource license. | ||
See the included file LICENSE or visit `opensource.org <http://opensource.org/licenses/MIT>`_ for more information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
""" | ||
This file is part of jiractl | ||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
""" | ||
|
||
import pbr.version | ||
|
||
try: | ||
__version__ = pbr.version.VersionInfo(__package__).version_string() | ||
except Exception: | ||
__version__ = "0.0.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
""" | ||
This file is part of jiractl | ||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
""" | ||
|
||
from cliff import app | ||
from cliff.commandmanager import CommandManager | ||
import jira | ||
|
||
import jiractl | ||
|
||
|
||
class JiraApp(app.App): | ||
"""Main cliff application class. | ||
Performs initialization of the command manager and | ||
configuration of basic engines. | ||
""" | ||
|
||
_jira = None | ||
|
||
def build_option_parser(self, description, version, argparse_kwargs=None): | ||
"""Specifies global options.""" | ||
parser = super(JiraApp, self).build_option_parser( | ||
description=description, version=version, argparse_kwargs=argparse_kwargs | ||
) | ||
|
||
parser.add_argument( | ||
"-s", "--server", | ||
metavar="URL", | ||
help="The Jira URL", | ||
) | ||
parser.add_argument( | ||
"-u", "--user", | ||
metavar="USERNAME", | ||
help="Jira user" | ||
) | ||
parser.add_argument( | ||
"-p", "--password", | ||
metavar="PASSWORD", | ||
help="Jira password" | ||
) | ||
return parser | ||
|
||
@property | ||
def jira(self): | ||
if self._jira is None: | ||
self._jira = jira.JIRA(server=self.options.server, basic_auth=(self.options.user, self.options.password)) | ||
return self._jira | ||
|
||
|
||
def run_app(cmd_mgr, argv=None): | ||
"""Runs application.""" | ||
return JiraApp( | ||
description="The command line interface for Jira REST API", | ||
version=jiractl.__version__, | ||
command_manager=cmd_mgr, | ||
deferred_help=True | ||
).run(argv) | ||
|
||
|
||
def main(argv=None): | ||
"""Entry point.""" | ||
return run_app(CommandManager(__package__, convert_underscores=True), argv) | ||
|
||
|
||
def debug(name, cmd_class, argv=None): | ||
"""Helper for debugging single command without package installation.""" | ||
import sys | ||
|
||
if argv is None: | ||
argv = sys.argv[1:] | ||
|
||
argv = [name] + argv + ["-v", "-v", "--debug"] | ||
cmd_mgr = CommandManager(__package__, convert_underscores=True) | ||
cmd_mgr.add_command(name, cmd_class) | ||
|
||
return run_app(cmd_mgr, argv) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
""" | ||
This file is part of jiractl | ||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
""" | ||
|
||
from cliff import command | ||
from cliff import lister | ||
from cliff import show | ||
|
||
|
||
def utf8(text): | ||
"""Converts text to utf8 encoded string""" | ||
return unicode(text, "utf8") | ||
|
||
|
||
class JiraCommand(command.Command): | ||
"""Executes command.""" | ||
|
||
|
||
class JiraShow(show.ShowOne): | ||
"""Executes command and displays result for one element.""" | ||
|
||
|
||
class JiraList(lister.Lister): | ||
"""Executes command and displays list of elements.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
""" | ||
This file is part of jiractl | ||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
""" | ||
|
||
from jiractl.commands import base | ||
|
||
|
||
class JiraCommentMixin(object): | ||
columns = ("id", "updated", "author", "body") | ||
|
||
def get_parser(self, prog_name): | ||
parser = super(JiraCommentMixin, self).get_parser(prog_name) | ||
parser.add_argument("--issue", type=base.utf8, help="Issue ID", required=True) | ||
return parser | ||
|
||
@staticmethod | ||
def format_comment(comment): | ||
"""Converts issue comment to tuple.""" | ||
return comment.id, comment.updated, comment.author.name, comment.body | ||
|
||
|
||
class ListComments(JiraCommentMixin, base.JiraList): | ||
"""Gets all comments for issue.""" | ||
|
||
def take_action(self, parsed_args): | ||
"""Get issue by id.""" | ||
return self.columns, [self.format_comment(x) for x in self.app.jira.comments(parsed_args.issue)] | ||
|
||
|
||
class AddComment(JiraCommentMixin, base.JiraShow): | ||
"""Adds new comment.""" | ||
|
||
def get_parser(self, prog_name): | ||
parser = super(AddComment, self).get_parser(prog_name) | ||
parser.add_argument("--body", type=base.utf8, help="Comment", required=True) | ||
parser.add_argument( | ||
"--visibility", type=base.utf8, metavar="TYPE:VALUE", help="Visibility of issue. format %(metavar)" | ||
) | ||
return parser | ||
|
||
def take_action(self, parsed_args): | ||
"""Adds new comment.""" | ||
visibility = None | ||
if parsed_args.visibility: | ||
visibility = dict(zip(("type", "value"), parsed_args.visibility.split(":", 2))) | ||
|
||
comment = self.app.jira.add_comment(parsed_args.issue, parsed_args.body, visibility=visibility) | ||
return self.columns, self.format_comment(comment) | ||
|
||
|
||
class EditComment(JiraCommentMixin, base.JiraCommand): | ||
"""Edit comment.""" | ||
|
||
def get_parser(self, prog_name): | ||
parser = super(EditComment, self).get_parser(prog_name) | ||
parser.add_argument("--id", type=base.utf8, help="Comment ID", required=True) | ||
parser.add_argument("--body", type=base.utf8, help="Comment", required=True) | ||
parser.add_argument("--visibility", type=base.utf8, help="Visibility in format type:value") | ||
return parser | ||
|
||
def take_action(self, parsed_args): | ||
"""Get issue by id.""" | ||
visibility = None | ||
if parsed_args.visibility: | ||
visibility = dict(zip(("type", "value"), parsed_args.visibility.split(":", 2))) | ||
|
||
comment = self.app.jira.comment(parsed_args.issue, parsed_args.id) | ||
comment.update(body=parsed_args.body, visibility=visibility) | ||
self.app.stdout.write("Done.\n") | ||
|
||
|
||
class ShowComment(JiraCommentMixin, base.JiraShow): | ||
"""Shows one comment.""" | ||
|
||
def get_parser(self, prog_name): | ||
parser = super(ShowComment, self).get_parser(prog_name) | ||
parser.add_argument("--id", type=base.utf8, help="Comment ID", required=True) | ||
return parser | ||
|
||
def take_action(self, parsed_args): | ||
"""Get issue by id.""" | ||
return self.columns, self.format_comment(self.app.jira.comment(parsed_args.issue, parsed_args.id)) |
Oops, something went wrong.