Skip to content

Commit

Permalink
Refactor + addition of console command
Browse files Browse the repository at this point in the history
  • Loading branch information
fmd committed Feb 8, 2014
1 parent e639fe6 commit 2ba1428
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
15 changes: 15 additions & 0 deletions lazyconf/console.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import os
import unittest
import lazyconf

from lib.schema import *
from lib.prompt import *
from lib.select import *
from lib.merge import *

# A function to be called from the setup entrypoint.
def conf():
lazyconf.Lazyconf().configure()

if __name__ == '__main__':
conf()
7 changes: 5 additions & 2 deletions lazyconf/lazyconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class Lazyconf():
def __init__(self):
self.prompt = Prompt()
self.data = None


# Creates the self.lazy_folder if it doesn't already exist, and writes the .gitignore.
def add_ignore(self, line):
Expand All @@ -34,6 +35,7 @@ def add_ignore(self, line):

handle.close()


# Finds all schema templates and prompts to choose one. Copies the file to self.lazy_folder.
def choose_schema(self, out_file):

Expand Down Expand Up @@ -76,7 +78,8 @@ def choose_schema(self, out_file):
sp, sf = os.path.split(out_file)
self.prompt.success('Saved to ' + self.lazy_folder + sf + '.')
return schema



# Goes through all the options in the data file, and prompts new values.
def configure_data(self, data, key_string = ''):

Expand Down Expand Up @@ -237,4 +240,4 @@ def _load(self, data_file):

def load(self, data_file):
self.data = self._load(data_file)
return self
return self
7 changes: 0 additions & 7 deletions lazyconf/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@
from lib.select import *
from lib.merge import *

# Call a configuration from this file.
def conf():
p = os.path.dirname(lazyconf.__file__)
if not p:
raise Exception("Could not find local path.")
l = Lazyconf().configure(p + '/schema/django.json', p + '/django.json', p + '/django.json')

class LazyTests(unittest.TestCase):

# Individually test the Merge class.
Expand Down
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@

setup(
name='lazyconf',
version='0.2.8',
version='0.3.5',
author='Fareed Dudhia',
author_email='fareeddudhia@gmail.com',
scripts=[l + 'test.py'],
package_dir={'' : 'lazyconf'},
packages=['lib'],
entry_points={
'console_scripts': ['lazyconf = console:conf',]},
data_files=[(t, [t + 'invalid.json',t + 'valid.json', t + 'noobject.json']),
(s, [s +'django.json', s + 'empty.json'])],
url='https://www.github.com/fmd/lazyconf',
Expand Down

0 comments on commit 2ba1428

Please sign in to comment.