Skip to content

Commit

Permalink
Rename package name.
Browse files Browse the repository at this point in the history
  • Loading branch information
jkawamoto committed Jun 28, 2016
1 parent e81c32c commit 91cabfa
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 41 deletions.
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
dargparse
dsargparse
==========
[![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat)](LICENSE)
[![Build Status](https://travis-ci.org/jkawamoto/dargparse.svg?branch=master)](https://travis-ci.org/jkawamoto/dargparse)
[![Code Climate](https://codeclimate.com/github/jkawamoto/dargparse/badges/gpa.svg)](https://codeclimate.com/github/jkawamoto/dargparse)
[![Build Status](https://travis-ci.org/jkawamoto/dsargparse.svg?branch=master)](https://travis-ci.org/jkawamoto/dsargparse)
[![Code Climate](https://codeclimate.com/github/jkawamoto/dsargparse/badges/gpa.svg)](https://codeclimate.com/github/jkawamoto/dsargparse)

dargparse is a wrapper of argparse library which prepares helps and descriptions
dsargparse is a wrapper of argparse library which prepares helps and descriptions
from docstrings. It also sets up functions to be run for each sub command,
and provides a helper function which parses args and run a selected command.

Expand All @@ -17,7 +17,7 @@ Suppose to make a following trivial greeting command consists of two subcommands
supplied as functions shown below.

```python
"""Sample command of dargparse package.
"""Sample command of dsargparse package.
This text will be used as description of this command.
"""
Expand Down Expand Up @@ -46,9 +46,9 @@ def goodbye(name): # pylint: disable=unused-argument
return 0
```

The `dargparse` reduces codes you need from the **before**
The `dsargparse` reduces codes you need from the **before**
```python
# Before dargparse
# Before dsargparse
import sys
import textwrap

Expand All @@ -59,7 +59,7 @@ def main():
"""
parser = argparse.ArgumentParser(
description=textwrap.dedent("""\
Sample command of dargparse package.
Sample command of argparse package.
This text will be used as description of this command.
"""))
Expand Down Expand Up @@ -100,15 +100,15 @@ if __name__ == "__main__":
```
to the **after**
```python
# After dargparse
# After dsargparse
import sys

import dargparse
import dsargparse

def main():
""" The main function.
"""
parser = dargparse.ArgumentParser(main=main)
parser = dsargparse.ArgumentParser(main=main)
subparsers = parser.add_subparsers()

greeting_cmd = subparsers.add_parser(greeting)
Expand All @@ -128,15 +128,15 @@ if __name__ == "__main__":

Usage
------
`dargparse` is a simple wrapper of the original `argparse`. To use it, install
this package and just adding `d` to your import command i.e. from
`import argparse` to `import dargparse`. In addition to all API `argparse` has,
`dargparse` updates three functions; constructor of `ArgumentParser` object,
`dsargparse` is a simple wrapper of the original `argparse`. To use it, install
this package and just adding `ds` to your import command i.e. from
`import argparse` to `import dsargparse`. In addition to all API `argparse` has,
`dsargparse` updates three functions; constructor of `ArgumentParser` object,
`ArgumentParser.add_argument`, and `add_parser` method of the action class made
by `ArgumentParser.add_subparsers()`, and give one new method
`ArgumentParser.parse_and_run`.

### `dargparse.ArgumentParser`
### `dsargparse.ArgumentParser`
In addition to the keyword arguments `argparse.ArgumentParser` takes,
this constructor has keyword argument `main` which takes the main function.

Expand Down
8 changes: 4 additions & 4 deletions dargparse.py → dsargparse.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#
# dargparse.py
# dsargparse.py
#
# Copyright (c) 2016 Junpei Kawamoto
#
# This software is released under the MIT License.
#
# http://opensource.org/licenses/mit-license.php
#
"""dargparse: docstring based argparse.
"""dsargparse: docstring based argparse.
dargparse is a wrapper of argparse library which prepares helps and descriptions
dsargparse is a wrapper of argparse library which prepares helps and descriptions
from docstrings. It also sets up functions to be run for each sub command,
and provides a helper function which parses args and run a selected command.
"""
Expand Down Expand Up @@ -140,7 +140,7 @@ class ArgumentParser(argparse.ArgumentParser):
This class takes same arguments as argparse.ArgumentParser to construct
a new instance. Additionally, it has a positional argument `main`,
which takes the main function of the script `dargparse` library called.
which takes the main function of the script `dsargparse` library called.
From the main function, it extracts doctstings to set command descriptions.
"""

Expand Down
14 changes: 7 additions & 7 deletions sample.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#! /usr/bin/env python
# pylint: disable=superfluous-parens
"""Sample command of dargparse package.
"""Sample command of dsargparse package.
This text will be used as description of this command.
"""
import sys

import dargparse
import dsargparse


def greeting(title, name): # pylint: disable=unused-argument
Expand Down Expand Up @@ -34,14 +34,14 @@ def goodbye(name): # pylint: disable=unused-argument
return 0


## Before `dargparse`.
## Before `dsargparse`.
# import textwrap
# def main():
# """ The main function.
# """
# parser = dargparse.ArgumentParser(
# parser = argparse.ArgumentParser(
# description=textwrap.dedent("""\
# Sample command of dargparse package.
# Sample command of argparse package.
#
# This text will be used as description of this command.
# """))
Expand Down Expand Up @@ -76,11 +76,11 @@ def goodbye(name): # pylint: disable=unused-argument
# args = parser.parse_args()
# return args.cmd(**args)

# After `dargparse`.
# After `dsargparse`.
def main():
""" The main function.
"""
parser = dargparse.ArgumentParser(main=main)
parser = dsargparse.ArgumentParser(main=main)
subparsers = parser.add_subparsers()

greeting_cmd = subparsers.add_parser(greeting)
Expand Down
10 changes: 5 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
""" Package information of docstrings based argparse.
"""
from setuptools import setup
import dargparse
import dsargparse

setup(
name="dargparse",
name="dsargparse",
version="0.1.0",
author="Junpei Kawamoto",
author_email="kawamoto.junpei@gmail.com",
description=dargparse.__doc__,
py_modules=["dargparse"],
description=dsargparse.__doc__,
py_modules=["dsargparse"],
test_suite="tests.suite",
license="MIT",
keywords="cli helper argparse",
url="https://github.com/jkawamoto/dargparse",
url="https://github.com/jkawamoto/dsargparse",
classifiers=[
"Development Status :: 3 - Alpha",
"Environment :: Console",
Expand Down
14 changes: 7 additions & 7 deletions tests/dargparse_test.py → tests/dsargparse_test.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
#! /usr/bin/env python
# pylint: disable=protected-access
#
# dargparse_test.py
# dsargparse_test.py
#
# Copyright (c) 2016 Junpei Kawamoto
#
# This software is released under the MIT License.
#
# http://opensource.org/licenses/mit-license.php
#
""" Unit tests for dargparse module.
""" Unit tests for dsargparse module.
"""
import textwrap
import unittest

import dargparse
import dsargparse


class TestParser(unittest.TestCase):
Expand All @@ -24,7 +24,7 @@ class TestParser(unittest.TestCase):
def test_full_document(self):
"""Test for a full information docstring.
"""
ans = dargparse._parse_doc(dargparse._parse_doc.__doc__)
ans = dsargparse._parse_doc(dsargparse._parse_doc.__doc__)

self.assertEqual(ans["headline"], "Parse a docstring.")
self.assertEqual(ans["description"], textwrap.dedent("""\
Expand All @@ -39,7 +39,7 @@ def test_full_document(self):
def test_minimum_document(self):
"""Test for a minimum docstring.
"""
ans = dargparse._parse_doc(dargparse._checker.__doc__)
ans = dsargparse._parse_doc(dsargparse._checker.__doc__)
self.assertEqual(
ans["headline"],
"Generate a checker which tests a given value not starts with keywords.")
Expand All @@ -51,7 +51,7 @@ def test_minimum_document(self):
def test_docstring_without_description(self):
""" Test for a docstring which doesn't have descriptions.
"""
ans = dargparse._parse_doc("""Test docstring.
ans = dsargparse._parse_doc("""Test docstring.
Args:
one: definition of one.
Expand All @@ -73,7 +73,7 @@ def test_docstring_without_description(self):
def test_docstring_without_args(self):
""" Test for a docstring which doesn't have args.
"""
ans = dargparse._parse_doc("""Test docstring.
ans = dsargparse._parse_doc("""Test docstring.
This function do something.
Expand Down
4 changes: 2 additions & 2 deletions tests/test_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import sys
import unittest

from . import dargparse_test
from . import dsargparse_test


def suite():
Expand All @@ -22,7 +22,7 @@ def suite():
loader = unittest.TestLoader()
res = unittest.TestSuite()

res.addTest(loader.loadTestsFromModule(dargparse_test))
res.addTest(loader.loadTestsFromModule(dsargparse_test))
return res


Expand Down

0 comments on commit 91cabfa

Please sign in to comment.