peppy :: editra :: syntax :: synextreg' :: ExtensionRegister :: Class ExtensionRegister
[frames] | no frames]

Class ExtensionRegister

object --+    
         |    
      dict --+
             |
            ExtensionRegister

A data storage class for managing mappings of file types to file extentions. The register is created as a singleton.


Status: initial implimentation

Instance Methods
 
Associate(self, ftype, ext)
Associate a given file type with the given file extension(s).
 
Disassociate(self, ftype, ext)
Disassociate a file type with a given extension or space separated list of extensions.
 
FileTypeFromExt(self, ext)
Returns the file type that is associated with the extension.
 
GetAllExtensions(self)
Returns a sorted list of all extensions registered
 
LoadDefault(self)
Loads the default settings
 
LoadFromConfig(self, config)
Load the extention register with values from a config file
 
SetAssociation(self, ftype, ext)
Like Associate but overrides any current settings instead of just adding to them.
new empty dictionary

__init__(self)
Initializes the register
 
__missing__(self, key)
Return the default value if an item is not found
 
__setitem__(self, i, y)
Ensures that only one filetype is associated with an extension at one time.
 
__str__(self)
Converts the Register to a string that is formatted for output to a config file.

Inherited from dict: __cmp__, __contains__, __delitem__, __eq__, __ge__, __getattribute__, __getitem__, __gt__, __hash__, __iter__, __le__, __len__, __lt__, __ne__, __repr__, clear, copy, fromkeys, get, has_key, items, iteritems, iterkeys, itervalues, keys, pop, popitem, setdefault, update, values

Inherited from object: __delattr__, __reduce__, __reduce_ex__, __setattr__

Static Methods
a new object with type S, a subtype of T
__new__(cls, *args, **kargs)
Maintain only a single instance of this object
Class Variables
  config = u'synmap'
  first = True
  instance = {u'LaTeX': ['aux', 'sty', 'tex'], u'Plain Text': ['...
Properties

Inherited from object: __class__

Method Details

Associate(self, ftype, ext)

 

Associate a given file type with the given file extension(s). The ext parameter can be a string of space separated extensions to allow for multiple associations at once.

Parameters:
  • ftype - file type description string
  • ext - file extension to associate

Disassociate(self, ftype, ext)

 

Disassociate a file type with a given extension or space separated list of extensions.

Parameters:
  • ftype - filetype description string
  • ext - extension to disassociate

FileTypeFromExt(self, ext)

 

Returns the file type that is associated with the extension. If no association is found Plain Text will be returned by default.

Parameters:
  • ext - extension to lookup

GetAllExtensions(self)

 

Returns a sorted list of all extensions registered

Returns:
list of all registered extensions

LoadDefault(self)

 

Loads the default settings

Postcondition: sets dictionary back to default installation state

LoadFromConfig(self, config)

 

Load the extention register with values from a config file

Parameters:
  • config - path to config file to load settings from

SetAssociation(self, ftype, ext)

 

Like Associate but overrides any current settings instead of just adding to them.

Parameters:
  • ftype - File type description string
  • ext - file extension to set

__init__(self)
(Constructor)

 

Initializes the register

Returns:
new empty dictionary

Overrides: object.__init__

__missing__(self, key)

 

Return the default value if an item is not found

Returns:
txt extension for plain text

__new__(cls, *args, **kargs)
Static Method

 

Maintain only a single instance of this object

Returns: a new object with type S, a subtype of T
instance of this class
Overrides: object.__new__

__setitem__(self, i, y)
(Index assignment operator)

 

Ensures that only one filetype is associated with an extension at one time. The behavior is that more recent settings override and remove associations from older settings.

Parameters:
  • i - key to set
  • y - value to set
Overrides: dict.__setitem__

__str__(self)
(Informal representation operator)

 

Converts the Register to a string that is formatted for output to a config file.

Returns:
the register as a string
Overrides: object.__str__

Class Variable Details

instance

Value:
{u'LaTeX': ['aux', 'sty', 'tex'], u'Plain Text': ['txt'], u'Java': ['j\
ava'], u'VHDL': ['vh', 'vhdl'], u'Diff File': ['diff', 'patch'], u'Jav\
aScript': ['js'], u'Makefile': ['mak', 'makefile'], u'Microsoft SQL': \
['mssql'], u'Perl': ['cgi', 'pl', 'pm', 'pod'], u'Lua': ['lua'], u'C-S\
hell Script': ['csh'], u'Ada': ['a', 'ada', 'adb', 'ads'], u'CPP': ['c\
++', 'cc', 'cpp', 'cxx', 'h++', 'hh', 'hpp', 'hxx'], u'Erlang': ['erl'\
], u'DOT': ['dot'], u'Fortran 95': ['f2k', 'f90', 'f95', 'fpp'], u'Kix\
': ['kix'], u'YAML': ['yaml', 'yml'], u'Python': ['py', 'python', 'pyw\
...