Skip to content
This repository was archived by the owner on Nov 4, 2022. It is now read-only.
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
42 changes: 0 additions & 42 deletions Makefile

This file was deleted.

56 changes: 0 additions & 56 deletions bin/getconf.2.py

This file was deleted.

53 changes: 0 additions & 53 deletions bin/getconf.3.py

This file was deleted.

1 change: 0 additions & 1 deletion bin/getconf.py

This file was deleted.

57 changes: 57 additions & 0 deletions bin/getconf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#! /usr/bin/env python
from __future__ import print_function

import sys
import os
import configtools
from optparse import make_option

def main(conf, args, opts):
if opts.dump:
conf.write(sys.stdout)
return 0

if opts.all:
for sec in args:
if conf.has_section(sec):
print("[%s]" % (sec))
items = conf.items(sec)
items.sort()
for (n, v) in items:
print("%s = %s" % (n, v))
print()
return 0

sep = ','
if opts.list:
sep = ' '

option = args[0]
for sec in args[1:]:
if conf.has_section(sec):
if conf.has_option(sec, option):
configtools.print_list(configtools.get_list(conf.get(sec, option)), sep)
return 0
return 1

options = [
make_option("-a", "--all", action="store_true", dest="all", help="print all items in section"),
make_option("-d", "--dump", action="store_true", dest="dump", help="print everything"),
make_option("-l", "--list", action="store_true", dest="list", help="print it as a shell list, translating commas to spaces"),
make_option("-L", "--listfiles", action="store_true", dest="listfiles", help="print the list of config files"),
]

if __name__ == '__main__':
opts, args = configtools.parse_args(options, usage='Usage: getconf.py [options] <item>|-a <section> [<section> ...]')
conf, files = configtools.init(opts)
if not conf:
sys.exit(1)
if opts.listfiles:
files.reverse()
print(files)
sys.exit(0)
if args:
status = main(conf, args, opts)
else:
status = 1
sys.exit(status)
57 changes: 0 additions & 57 deletions bin/gethosts.3.py

This file was deleted.

7 changes: 3 additions & 4 deletions bin/gethosts.2.py → bin/gethosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@

import sys
import os
import configtools
import configtools
from optparse import make_option

def main(conf, args, opts):
if not conf:
return 1

sep = ','
if opts.list:
sep = ' '
Expand Down Expand Up @@ -55,5 +52,7 @@ def main(conf, args, opts):
if __name__ == '__main__':
opts, args = configtools.parse_args(options)
conf, files = configtools.init(opts)
if not conf:
sys.exit(1)
status = main(conf, args, opts)
sys.exit(status)
1 change: 0 additions & 1 deletion intro.org
Original file line number Diff line number Diff line change
Expand Up @@ -210,4 +210,3 @@ servers = gprfs00[3-8]

[fn:1] if necessary, that limitation gives an ugly way to get a
literal 'foo[1-3]' by specifying 'foo[][1-3]'.

41 changes: 0 additions & 41 deletions profile

This file was deleted.

13 changes: 7 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from distutils.core import setup

setup(name='configtools',
version='0.2',
description='Simple tools for using config files',
author='Nick Dokos',
author_email='ndokos@redhat.com',
url='http://foo',
setup(name = 'configtools',
version = '0.3',
description = 'Simple tools for using config files',
author = 'Nick Dokos',
author_email = 'ndokos@redhat.com',
url = 'http://foo',
packages = ['configtools'],
scripts = ['bin/getconf.py', 'bin/gethosts.py',],
)
Loading