Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
creado sub-módulo de configuraciones
limpieza de código, carga configuraciones desde archivo externo, optimización de funciones
- Loading branch information
Showing
6 changed files
with
157 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
''' | ||
Created on 30/10/2011 | ||
@author: Fernando | ||
Sub-Modulo de Gestion de Archivos de Configuracion | ||
''' | ||
|
||
import re | ||
|
||
# -- carga un archivo de configuracion | ||
def load(filename): | ||
try: configfile = open(filename, "r") | ||
except Exception, e: raise e | ||
try: configtext = configfile.read() | ||
except Exception, e: raise e | ||
# Compile a pattern that matches our key-value line structure | ||
pattern = re.compile("\\n([\w_]+)[\t ]*([\w: \\\/~.-]+)") | ||
# Find all matches to this pattern in the text of the <strong class="highlight">config</strong> <strong class="highlight">file</strong> | ||
tuples = re.findall(pattern, configtext) | ||
# Create a new dictionary and fill it: for every tuple (key, value) in | ||
# the 'tuples' list, set ret[key] to value | ||
configuraciones = dict() | ||
for x in tuples: configuraciones[x[0]] = x[1] | ||
# Return the fully-loaded dictionary object | ||
return configuraciones |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
logfile = aoc.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters