summaryrefslogtreecommitdiffstats
path: root/ipa
diff options
context:
space:
mode:
authorJason Gerard DeRose <jderose@redhat.com>2008-08-08 17:11:29 +0000
committerJason Gerard DeRose <jderose@redhat.com>2008-08-08 17:11:29 +0000
commit8e468248155947075689e6d01c3ab90fbd9f1643 (patch)
tree0125fd3214105714fd8bdcb0585554470d786dbb /ipa
parentf656e31a7ee366c57d959e4a3e4b9a935eb2cc07 (diff)
downloadfreeipa-8e468248155947075689e6d01c3ab90fbd9f1643.tar.gz
freeipa-8e468248155947075689e6d01c3ab90fbd9f1643.tar.xz
freeipa-8e468248155947075689e6d01c3ab90fbd9f1643.zip
81: Switch from tab to 4-space indentation
Diffstat (limited to 'ipa')
-rwxr-xr-xipa210
1 files changed, 105 insertions, 105 deletions
diff --git a/ipa b/ipa
index 5606b3730..626eb0458 100755
--- a/ipa
+++ b/ipa
@@ -31,54 +31,54 @@ from ipalib.startup import api
TAB_WIDTH = 2
def _(msg):
- """
- Dummy gettext function for testing.
- """
- return msg
+ """
+ Dummy gettext function for testing.
+ """
+ return msg
class row(object):
- def __init__(self, tab, c1, c2=None):
- assert type(tab) is int
- assert type(c1) in (str, int)
- assert type(c2) is str or c2 is None
- self.tab = tab
- self.c1 = c1
- self.c2 = c2
-
- def __len__(self):
- return len(str(self.c1))
-
- def pretty_print(self, just):
- tab = ' ' * (self.tab * TAB_WIDTH)
- if self.c2 is None:
- print '%s%s' % (tab, self.c1)
- else:
- if type(self.c1) is int:
- c1 = str(self.c1).rjust(just)
- else:
- c1 = self.c1.ljust(just)
- print '%s%s %s' % (tab, c1, self.c2)
+ def __init__(self, tab, c1, c2=None):
+ assert type(tab) is int
+ assert type(c1) in (str, int)
+ assert type(c2) is str or c2 is None
+ self.tab = tab
+ self.c1 = c1
+ self.c2 = c2
+
+ def __len__(self):
+ return len(str(self.c1))
+
+ def pretty_print(self, just):
+ tab = ' ' * (self.tab * TAB_WIDTH)
+ if self.c2 is None:
+ print '%s%s' % (tab, self.c1)
+ else:
+ if type(self.c1) is int:
+ c1 = str(self.c1).rjust(just)
+ else:
+ c1 = self.c1.ljust(just)
+ print '%s%s %s' % (tab, c1, self.c2)
def pretty_print(rows):
- rows = tuple(rows)
- def get_lengths():
- yield 0
- for r in rows:
- if r.c2 is not None:
- yield len(r)
- max_len = max(get_lengths())
- for r in rows:
- r.pretty_print(max_len)
+ rows = tuple(rows)
+ def get_lengths():
+ yield 0
+ for r in rows:
+ if r.c2 is not None:
+ yield len(r)
+ max_len = max(get_lengths())
+ for r in rows:
+ r.pretty_print(max_len)
def print_commands():
- print 'Commands:'
- m = api.max_cmd_len
- for cmd in api.cmd:
- print ' %s %s' % (str(cmd).ljust(m), cmd.get_doc(_))
+ print 'Commands:'
+ m = api.max_cmd_len
+ for cmd in api.cmd:
+ print ' %s %s' % (str(cmd).ljust(m), cmd.get_doc(_))
def print_help(cmd):
- print 'Help on %s' % cmd
+ print 'Help on %s' % cmd
@@ -94,79 +94,79 @@ def print_help(cmd):
def print_api():
- def iter_api(tab):
- for name in api:
- ns = getattr(api, name)
- yield row(
- tab,
- name,
- repr(ns),
- )
- for i in ns:
- yield row(
- tab + 1,
- i.name,
- repr(i)
- )
-
- def iter_obj(tab):
- for obj in api.obj:
- yield row(
- tab,
- obj.name,
- repr(obj),
- )
- for (n, f) in [('mthd', '.%s()'), ('prop', '.%s')]:
- ns = getattr(obj, n)
- yield row(
- tab + 1,
- n,
- repr(ns),
- )
- for attr in ns:
- yield row(
- tab + 2,
- f % attr.name,
- repr(attr),
- )
-
- def iter_summary(tab):
- for name in api:
- ns = getattr(api, name)
- yield row(
- tab,
- len(ns),
- name
- )
-
- def print_heading(h):
- print '\n%s:' % h
- print '-' * (len(h) + 1)
-
- tab = 1
- print_heading('API Overview')
- pretty_print(iter_api(tab))
-
- print_heading('Object Details')
- pretty_print(iter_obj(tab))
-
- print_heading('Summary')
- pretty_print(iter_summary(tab))
+ def iter_api(tab):
+ for name in api:
+ ns = getattr(api, name)
+ yield row(
+ tab,
+ name,
+ repr(ns),
+ )
+ for i in ns:
+ yield row(
+ tab + 1,
+ i.name,
+ repr(i)
+ )
+
+ def iter_obj(tab):
+ for obj in api.obj:
+ yield row(
+ tab,
+ obj.name,
+ repr(obj),
+ )
+ for (n, f) in [('mthd', '.%s()'), ('prop', '.%s')]:
+ ns = getattr(obj, n)
+ yield row(
+ tab + 1,
+ n,
+ repr(ns),
+ )
+ for attr in ns:
+ yield row(
+ tab + 2,
+ f % attr.name,
+ repr(attr),
+ )
+
+ def iter_summary(tab):
+ for name in api:
+ ns = getattr(api, name)
+ yield row(
+ tab,
+ len(ns),
+ name
+ )
+
+ def print_heading(h):
+ print '\n%s:' % h
+ print '-' * (len(h) + 1)
+
+ tab = 1
+ print_heading('API Overview')
+ pretty_print(iter_api(tab))
+
+ print_heading('Object Details')
+ pretty_print(iter_obj(tab))
+
+ print_heading('Summary')
+ pretty_print(iter_summary(tab))
if len(sys.argv) < 2:
- print_commands()
- print 'Usage: ipa COMMAND [OPTIONS]'
- sys.exit(2)
+ print_commands()
+ print 'Usage: ipa COMMAND [OPTIONS]'
+ sys.exit(2)
name= sys.argv[1]
if name == '_api_':
- print_api()
- sys.exit()
+ print_api()
+ sys.exit()
elif name not in api.cmd:
- print_commands()
- print 'ipa: ERROR: unknown command %r' % name
- sys.exit(2)
+ print_commands()
+ print 'ipa: ERROR: unknown command %r' % name
+ sys.exit(2)
api.cmd[name]()