Back to index

python-cliapp  1.20120630
Public Member Functions | Public Attributes | Static Public Attributes | Properties | Private Attributes
cliapp.settings.ByteSizeSetting Class Reference
Inheritance diagram for cliapp.settings.ByteSizeSetting:
Inheritance graph
[legend]
Collaboration diagram for cliapp.settings.ByteSizeSetting:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def parse_human_size
def default_metavar
def get_value
def set_value
def call_get_value
def call_set_value
def has_value
def parse_value
def format

Public Attributes

 names
 help
 metavar
 group

Static Public Attributes

string action = 'store'
string type = 'string'
int nargs = 1
 choices = None

Properties

 value = property(call_get_value, call_set_value)

Private Attributes

 _string_value

Detailed Description

Definition at line 144 of file settings.py.


Member Function Documentation

def cliapp.settings.Setting.call_get_value (   self) [inherited]

Definition at line 50 of file settings.py.

00050 
00051     def call_get_value(self):
00052         return self.get_value()
        

Here is the call graph for this function:

def cliapp.settings.Setting.call_set_value (   self,
  value 
) [inherited]

Definition at line 53 of file settings.py.

00053 
00054     def call_set_value(self, value):
00055         self.set_value(value)

Here is the call graph for this function:

Reimplemented from cliapp.settings.Setting.

Definition at line 169 of file settings.py.

00169 
00170     def default_metavar(self):
00171         return 'SIZE'

def cliapp.settings.Setting.format (   self) [inherited]

Reimplemented in cliapp.settings.StringListSetting.

Definition at line 64 of file settings.py.

00064 
00065     def format(self): # pragma: no cover
00066         return str(self.value)
00067 

Reimplemented from cliapp.settings.Setting.

Definition at line 172 of file settings.py.

00172 
00173     def get_value(self):
00174         return long(self._string_value)
        
def cliapp.settings.Setting.has_value (   self) [inherited]

Reimplemented in cliapp.settings.StringListSetting.

Definition at line 58 of file settings.py.

00058 
00059     def has_value(self):
00060         return self.value is not None

Parse a size using suffix into plain bytes.

Definition at line 146 of file settings.py.

00146 
00147     def parse_human_size(self, size):
00148         '''Parse a size using suffix into plain bytes.'''
00149         
00150         m = re.match(r'''(?P<number>\d+(\.\d+)?) \s* 
00151                          (?P<unit>k|ki|m|mi|g|gi|t|ti)? b? \s*$''',
00152                      size.lower(), flags=re.X)
00153         if not m:
00154             return 0
00155         else:
00156             number = float(m.group('number'))
00157             unit = m.group('unit')
00158             units = {
00159                 'k': 10**3,
00160                 'm': 10**6,
00161                 'g': 10**9,
00162                 't': 10**12,
00163                 'ki': 2**10,
00164                 'mi': 2**20,
00165                 'gi': 2**30,
00166                 'ti': 2**40,
00167             }
00168             return long(number * units.get(unit, 1))

Here is the caller graph for this function:

def cliapp.settings.Setting.parse_value (   self,
  string 
) [inherited]

Reimplemented in cliapp.settings.StringListSetting.

Definition at line 61 of file settings.py.

00061 
00062     def parse_value(self, string):
00063         self.value = string

def cliapp.settings.ByteSizeSetting.set_value (   self,
  value 
)

Reimplemented from cliapp.settings.Setting.

Definition at line 175 of file settings.py.

00175 
00176     def set_value(self, value):
00177         if type(value) == str:
00178             value = self.parse_human_size(value)
00179         self._string_value = str(value)
00180 

Here is the call graph for this function:


Member Data Documentation

Reimplemented from cliapp.settings.Setting.

Definition at line 178 of file settings.py.

string cliapp.settings.Setting.action = 'store' [static, inherited]

Reimplemented in cliapp.settings.BooleanSetting, and cliapp.settings.StringListSetting.

Definition at line 29 of file settings.py.

cliapp.settings.Setting.choices = None [static, inherited]

Reimplemented in cliapp.settings.ChoiceSetting.

Definition at line 32 of file settings.py.

Definition at line 39 of file settings.py.

Definition at line 37 of file settings.py.

Definition at line 38 of file settings.py.

Definition at line 35 of file settings.py.

int cliapp.settings.Setting.nargs = 1 [static, inherited]

Reimplemented in cliapp.settings.BooleanSetting.

Definition at line 31 of file settings.py.

string cliapp.settings.Setting.type = 'string' [static, inherited]

Property Documentation

Reimplemented in cliapp.settings.StringListSetting.

Definition at line 56 of file settings.py.


The documentation for this class was generated from the following file: