Subversion Repositories basico

Compare Revisions

Ignore whitespace Rev 127 → Rev 128

/branches/BR-0.3/basico/callbacks.py
67,7 → 67,8
def actions_browse(self, *args):
SAP_NOTE_URL = self.settings.get('SAP', 'SAP_NOTE_URL')
sapnoteview = self.gui.get_widget('viewmenu')
sapnotes = sapnoteview.get_selected_notes()
visor = self.gui.get_widget('visor')
sapnotes = visor.get_toggled()
lurl = []
for sid in sapnotes:
url = SAP_NOTE_URL % sid
81,7 → 82,7
sapnoteview = self.gui.get_widget('viewmenu')
sapnotes = sapnoteview.get_selected_notes()
sapnotes.sort()
winroot = self.gui.get_widget('mainwinow')
winroot = self.gui.get_widget('mainwindow')
 
dialog = Gtk.MessageDialog(winroot, 0, Gtk.MessageType.WARNING,
Gtk.ButtonsType.OK_CANCEL, "Are you sure?")
254,10 → 255,10
 
def actions_export_csv(self, *args):
db = self.get_service('DB')
rootwin = self.gui.get_widget('mainwndow')
winroot = self.gui.get_widget('mainwndow')
sapnoteview = self.gui.get_widget('viewmenu')
sapnotes = sapnoteview.get_selected_notes()
dialog = Gtk.FileChooserDialog("Save file", rootwin,
dialog = Gtk.FileChooserDialog("Save file", winroot,
Gtk.FileChooserAction.SAVE,
(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
Gtk.STOCK_SAVE, Gtk.ResponseType.OK))
495,7 → 496,7
def import_notes_from_file(self):
db = self.get_service('DB')
notebook = self.gui.get_widget('notebook')
rootwin = self.gui.get_widget('mainwinow')
rootwin = self.gui.get_widget('mainbox')
 
dialog = Gtk.FileChooserDialog("Select Basico JSON file", rootwin,
Gtk.FileChooserAction.OPEN,
532,7 → 533,7
driver = self.get_service('Driver')
 
notebook = self.gui.get_widget('notebook')
winroot = self.gui.get_widget('mainwinow')
winroot = self.gui.get_widget('mainwindow')
sapnotes = []
bag = set()
#~ txtnotes = self.gui.get_widget('txtSAPNotes')
626,13 → 627,13
self.log.debug("Rebuild database...")
 
db = self.get_service('DB')
DB_DIR = self.get_var('DB', 'local')
CACHE_DIR = self.get_var('CACHE', 'local')
 
#~ FSAPNOTE = DB_DIR + sid + '.xml'
#~ FSAPNOTE = CACHE_DIR + sid + '.xml'
#~ if path is None:
#~ path = DB_DIR
#~ path = CACHE_DIR
 
files = glob.glob("%s%s*.xml" % (DB_DIR, SEP))
files = glob.glob("%s%s*.xml" % (CACHE_DIR, SEP))
sap = self.app.get_service('SAP')
for filename in files:
self.log.debug("Filename: %s" % filename)
/branches/BR-0.3/basico/database.py
36,12 → 36,12
self.stats['type'] = set()
self.stats['version'] = set()
#~ self.stats['releaseon'] = set()
#~ self.rebuild_from_dir()
#~
 
 
def store(self, sapnote, html):
DB_DIR = self.get_var('DB', 'local')
FSAPNOTE = DB_DIR + sapnote + '.xml'
CACHE_DIR = self.get_var('CACHE', 'local')
FSAPNOTE = CACHE_DIR + sapnote + '.xml'
 
try:
f = open(FSAPNOTE, 'w')
54,13 → 54,13
 
def rebuild_from_dir(self, path=None):
db = self.get_service('DB')
DB_DIR = self.get_var('DB', 'local')
CACHE_DIR = self.get_var('CACHE', 'local')
 
#~ FSAPNOTE = DB_DIR + sid + '.xml'
#~ FSAPNOTE = CACHE_DIR + sid + '.xml'
if path is None:
path = DB_DIR
path = CACHE_DIR
 
files = glob.glob("%s%s*.xml" % (DB_DIR, SEP))
files = glob.glob("%s%s*.xml" % (CACHE_DIR, SEP))
sap = self.app.get_service('SAP')
for filename in files:
self.log.debug("Filename: %s" % filename)
78,20 → 78,20
db.store(sid, content)
valid = True
 
cb =self.app.get_service('Callbacks')
cb = self.app.get_service('Callbacks')
cb.refresh_view()
 
 
def get_sapnote_content(self, sid):
DB_DIR = self.get_var('DB', 'local')
FSAPNOTE = DB_DIR + sid + '.xml'
CACHE_DIR = self.get_var('CACHE', 'local')
FSAPNOTE = CACHE_DIR + sid + '.xml'
content = open(FSAPNOTE, 'r').read()
return content
 
 
def is_stored(self, sid):
DB_DIR = self.get_var('DB', 'local')
fsapnote = DB_DIR + sid + '.xml'
CACHE_DIR = self.get_var('CACHE', 'local')
fsapnote = CACHE_DIR + sid + '.xml'
stored = os.path.exists(fsapnote)
#~ self.log.debug("\tSAP Note %s stored in database? %s" % (sid, stored))