mlhim-specs-dev team mailing list archive
-
mlhim-specs-dev team
-
Mailing list archive
-
Message #00605
[Branch ~cdd-dev/cdd/trunk] Rev 186: Moved all classes, functions and data from cdg_custom.py and cdg_extra.py to cdg_main.py
------------------------------------------------------------
revno: 186
committer: Eduardo César <xcesar@xxxxxxxxx>
branch nick: cdd
timestamp: Thu 2012-07-19 21:25:17 -0300
message:
Moved all classes, functions and data from cdg_custom.py and cdg_extra.py to cdg_main.py
removed:
src/cdg_custom.py
src/cdg_extra.py
modified:
src/cdd.py
src/cdg_main.py
src/mlhim2.py
--
lp:cdd
https://code.launchpad.net/~cdd-dev/cdd/trunk
Your team MLHIM Specifications Developers is subscribed to branch lp:cdd.
To unsubscribe from this branch go to https://code.launchpad.net/~cdd-dev/cdd/trunk/+edit-subscription
=== modified file 'src/cdd.py'
--- src/cdd.py 2012-07-19 22:21:28 +0000
+++ src/cdd.py 2012-07-20 00:25:17 +0000
@@ -7,8 +7,7 @@
import wx
from wx.lib.wordwrap import wordwrap
-import cdg_custom
-import cdg_extra
+import cdg_main
import mlhim2
gettext.bindtextdomain('CDD','locales/en')
@@ -17,7 +16,7 @@
#Where the info will be stored
-info = cdg_custom.Info()
+info = cdg_main.Info()
class MainFrame(wx.Frame):
def __init__(self, parent, id):
@@ -160,7 +159,7 @@
_data = mlhim2.Metadata(self)
result = _data.ShowModal()
if result == wx.ID_OK:
- cdg_extra.extract_info(_data, info)
+ cdg_main.extract_info(_data, info)
_data.c.get_panel_configs()
_data.c.save_config()
@@ -296,13 +295,13 @@
# Get the path
- path = cdg_extra.get_path(self)
+ path = cdg_main.get_path(self)
if not path:
return
info.generate_file(path)
# Show dialog
- cdg_extra.popup_message(self, '%s.xsd' % info.ccd_id, 'Generated the file', wx.OK | wx.ICON_INFORMATION)
+ cdg_main.popup_message(self, '%s.xsd' % info.ccd_id, 'Generated the file', wx.OK | wx.ICON_INFORMATION)
#TODO: Eduardo to add the generator portion here.
=== removed file 'src/cdg_custom.py'
--- src/cdg_custom.py 2012-07-20 00:12:06 +0000
+++ src/cdg_custom.py 1970-01-01 00:00:00 +0000
@@ -1,228 +0,0 @@
-import os
-import sys
-import uuid
-import ConfigParser
-from xml.sax.saxutils import escape
-
-class Info(object):
- def __init__(self):
- self.title = ''
- self.description = ''
- self.creator = ''
- self.creator_email = ''
- self.contributor = ''
-
- self.publisher = ''
- self.subject = ''
- self.source = ''
- self.rights = ''
- self.relation = ''
- self.coverage = ''
-
- self.language = ''
-
- self.date = ''
-
- self.ccd_id = "ccd_"+str(uuid.uuid4()).replace('-','_')
-
- def get_info(self, title, description, date, creator, creator_email, contributor, language, publisher, subject, source, rights, relation, coverage):
- self.title = title
- self.description = description
- self.creator = creator
- self.creator_email = creator_email
- self.contributor = contributor
-
- self.publisher = publisher
- self.subject = subject
- self.source = source
- self.rights = rights
- self.relation = relation
- self.coverage = coverage
-
- self.language = language
-
- self.date = date
-
-
- def generate_file(self, path):
-
-
- UUID_definition = "ct_"+str(uuid.uuid4()).replace('-','_')
- UUID_string = "ct_"+str(uuid.uuid4()).replace('-','_')
-
- schema = self.ccd_id + ".xsd"
-
- contributors_formated = '<dc:contributor>' + \
- '</dc:contributor>\n<dc:contributor>'.join([ escape(i).strip() for i in self.contributor.split(';')]) + \
- '</dc:contributor>'
-
- f = open(path+'/'+schema,'w')
-
- f.write("""<?xml version="1.1" encoding="UTF-8"?>
-
-<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
- xmlns:mlhim2="http://www.mlhim.org/xmls/mlhim2/2_3_0"
- elementFormDefault="qualified"
- targetNamespace="http://www.mlhim.org/xmls/mlhim2/2_3_0">
-
- <xs:annotation>
- <xs:documentation source="http://www.mlhim.org" xml:lang="{language}">
- This is a {title} Concept Constraint Definition schema file (CCD).
-
- <rdf:RDF
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:dc= "http://purl.org/dc/elements/1.1/">
-
- <rdf:Description rdf:about="http://www.hkcr.net/ccd/{ccd_id}">
- <dc:title>{title}</dc:title>
- <dc:creator>{creator} <{creator_email}> </dc:creator>
- {contributors}
- <dc:subject>{subject}</dc:subject>
- <dc:source>{source}</dc:source>
- <dc:rights>{rights}</dc:rights>
- <dc:relation>{relation}</dc:relation>
- <dc:coverage>{coverage}</dc:coverage>
- <dc:type>{resource_type}</dc:type>
- <dc:identifier>{identifier}</dc:identifier>
- <dc:description>{description}</dc:description>
- <dc:publisher>{publisher}</dc:publisher>
- <dc:date>{date}</dc:date>
- <dc:format>{resource_format}</dc:format>
- <dc:language>{language}</dc:language>
- </rdf:Description>
-
- </rdf:RDF>
-
- </xs:documentation>
- </xs:annotation>
-
- <xs:include schemaLocation="http://www.mlhim.org/xmls/mlhim2/2_3_0/mlhim2.xsd"/>
-
- <xs:element name='CCD' type="mlhim2:{ccd_id}"/>
- <xs:complexType name="{ccd_id}">
- <xs:complexContent>
- <xs:restriction base="mlhim2:CCDType">
- <xs:sequence>
- <xs:element name="definition" minOccurs="1" maxOccurs="1" type="mlhim2:{UUID_definition}"/>
- </xs:sequence>
- </xs:restriction>
- </xs:complexContent>
- </xs:complexType>
-
-</xs:schema>
-""".format(ccd_id = self.ccd_id,
- UUID_definition = UUID_definition,
- UUID_DvString = UUID_string,
-
- title = escape(self.title),
- description = escape(self.description),
- date = self.date,
- creator = escape(self.creator),
- creator_email = escape(self.creator_email),
- contributors = contributors_formated,
- language = self.language,
- publisher = escape(self.publisher),
- subject = escape(self.subject),
- source = escape(self.source),
- rights = escape(self.rights),
- relation = escape(self.relation),
- coverage = escape(self.coverage),
-
- resource_type = "MLHIM Concept Constraint Definition (CCD)",
- resource_format = "text/xml",
- identifier = self.ccd_id,
-
- ))
-
-
- f.write("<!-- Here are some UUIDs to use for complexType names:\n\n")
-
- for x in range(0,10):
- f.write("ct_"+str(uuid.uuid4()).replace('-','_')+"\n\n")
-
- f.write("-->")
-
- f.close()
-
-class Config(object):
- def __init__(self, panel):
- if sys.platform.startswith('linux'):
- home = os.environ['HOME']
- elif sys.platform.startswith('win'):
- home = os.environ['HOMEDRIVE'] + '/' +os.environ['HOMEPATH']
-
- else:
- home = './'
- self.configdir = home + '/.mlhim'
- self.configname = self.configdir + '/' + 'metadata.cfg'
- self.panel = panel
-
- self.config = ConfigParser.SafeConfigParser({
- 'title' : '',
- 'description' : '',
- 'creator' : '',
- 'creator_email' : '',
- 'contributor' : '',
- 'publisher' : '',
- 'subject' : '',
- 'source' : '',
- 'rights' : 'CC-BY http://creativecommons.org/licenses/by/3.0/',
- 'relation' : 'None',
- 'coverage' : 'Universal',
- 'language' : '76',
- 'choice_definition' : '0',
- })
-
- def read_config(self):
- try:
- if not self.config.read(self.configname):
- self.make_config()
- except:
- self.save_config()
-
-
- def make_config(self):
- if not os.path.exists(self.configdir):
- os.mkdir(self.configdir)
- # with open(self.configname, 'wb') as configfile:
- # self.config.write(configfile)
-
- def save_config(self):
- with open(self.configname, 'wb') as configfile:
- configfile.write('# Concept Definition Generator Configuration\n# Do not edit the text to the left of the equal symbol (=)\n\n')
- self.config.write(configfile)
-
-
- def get_panel_configs(self):
- self.config.set('DEFAULT', 'title', self.panel.text_ctrl_title.GetValue().encode('utf8'))
- self.config.set('DEFAULT', 'description', self.panel.text_ctrl_description.GetValue().encode('utf8'))
- self.config.set('DEFAULT', 'creator', self.panel.text_ctrl_creator.GetValue().encode('utf8'))
- self.config.set('DEFAULT', 'creator_email', self.panel.text_ctrl_creator_email.GetValue().encode('utf8'))
- self.config.set('DEFAULT', 'contributor', self.panel.text_ctrl_contributors.GetValue().encode('utf8'))
-
- self.config.set('DEFAULT', 'publisher', self.panel.text_ctrl_publisher.GetValue().encode('utf8'))
- self.config.set('DEFAULT', 'subject', self.panel.text_ctrl_subject.GetValue().encode('utf8'))
- self.config.set('DEFAULT', 'source', self.panel.text_ctrl_source.GetValue().encode('utf8'))
- self.config.set('DEFAULT', 'rights', self.panel.text_ctrl_rights.GetValue().encode('utf8'))
- self.config.set('DEFAULT', 'relation', self.panel.text_ctrl_relation.GetValue().encode('utf8'))
- self.config.set('DEFAULT', 'coverage', self.panel.text_ctrl_coverage.GetValue().encode('utf8'))
-
- self.config.set('DEFAULT', 'language', str(self.panel.choice_lang.GetSelection()))
-
- def set_panel_configs(self):
- self.panel.text_ctrl_title.SetValue(self.config.get('DEFAULT', 'title'))
- self.panel.text_ctrl_description.SetValue(self.config.get('DEFAULT', 'description'))
- self.panel.text_ctrl_creator.SetValue(self.config.get('DEFAULT', 'creator'))
- self.panel.text_ctrl_creator_email.SetValue(self.config.get('DEFAULT', 'creator_email'))
- self.panel.text_ctrl_contributors.SetValue(self.config.get('DEFAULT', 'contributor'))
-
- self.panel.text_ctrl_publisher.SetValue(self.config.get('DEFAULT', 'publisher'))
- self.panel.text_ctrl_subject.SetValue(self.config.get('DEFAULT', 'subject'))
- self.panel.text_ctrl_source.SetValue(self.config.get('DEFAULT', 'source'))
- self.panel.text_ctrl_rights.SetValue(self.config.get('DEFAULT', 'rights'))
- self.panel.text_ctrl_relation.SetValue(self.config.get('DEFAULT', 'relation'))
- self.panel.text_ctrl_coverage.SetValue(self.config.get('DEFAULT', 'coverage'))
-
- self.panel.choice_lang.SetSelection(int(self.config.get('DEFAULT', 'language')))
-
-
=== removed file 'src/cdg_extra.py'
--- src/cdg_extra.py 2012-07-19 22:21:28 +0000
+++ src/cdg_extra.py 1970-01-01 00:00:00 +0000
@@ -1,87 +0,0 @@
-# -*- coding: utf-8 -*-
-import os
-import locale
-import sys
-
-import wx
-from wx.lib.wordwrap import wordwrap
-
-def help_box(self):
-
- dlg = wx.MessageDialog(self, """
-Emails are formatted as:
-Timothy W. Cook <timothywayne.cook@xxxxxxxxx>
-
-Separate multiple contributors with a semi-colon and format them as:
-Eduardo Cesar <xcesar@xxxxxxxxx>; Luciana Cavalini <lutricav@xxxxxxxxx>
-""",
- 'Help',
- wx.OK | wx.ICON_INFORMATION
- #wx.YES_NO | wx.NO_DEFAULT | wx.CANCEL | wx.ICON_INFORMATION
- )
- dlg.ShowModal()
- dlg.Destroy()
-
-
-def get_lang_list():
- l = list(set(locale.locale_alias.keys()))
- l.sort()
- l2 = [i.replace('_','-')[0:3] + i[3:].upper() for i in l if ((len(i) < 6 and '_' in i) or len(i) == 2)]
-
- return l2
-
-def get_path(self):
- path = os.getcwd()
-
- dlg = wx.DirDialog(self, "Choose a directory to put the generated files:",
- path,
- style=wx.DD_DEFAULT_STYLE
- #| wx.DD_DIR_MUST_EXIST
- #| wx.DD_CHANGE_DIR
- )
-
-
- if dlg.ShowModal() == wx.ID_OK:
- path = dlg.GetPath()
- else:
- return None
-
- dlg.Destroy()
- return path
-
-
-def popup_message(self, msg, tag, icons):
- dlg = wx.MessageDialog(self, msg, tag, icons)
- result = dlg.ShowModal()
- dlg.Destroy()
- if result == wx.ID_OK:
- return True
- else:
- return False
-
-def extract_info(self, info):
- title = self.text_ctrl_title.GetValue().encode('utf8')
- description = self.text_ctrl_description.GetValue().encode('utf8')
- creator = self.text_ctrl_creator.GetValue().encode('utf8')
- creator_email = self.text_ctrl_creator_email.GetValue().encode('utf8')
- contributor = self.text_ctrl_contributors.GetValue().encode('utf8')
-
- publisher = self.text_ctrl_publisher.GetValue().encode('utf8')
- subject = self.text_ctrl_subject.GetValue().encode('utf8')
- source = self.text_ctrl_source.GetValue().encode('utf8')
- rights = self.text_ctrl_rights.GetValue().encode('utf8')
- relation = self.text_ctrl_relation.GetValue().encode('utf8')
- coverage = self.text_ctrl_coverage.GetValue().encode('utf8')
-
- language = self.choice_lang.GetStringSelection()
-
- tempo = self.datepicker_ctrl_date.GetValue()
- date = '{Y}-{M}-{D:02}'.format(Y=tempo.GetYear(), M=tempo.GetMonth(), D=tempo.GetDay())
-
- info.get_info(title, description, date, creator, creator_email, contributor, language, publisher, subject, source, rights, relation, coverage)
- # # Test if the mandatary fields are with something
- # if not (title and date and description and creator and subject and rights):
- # cdg_extra.popup_message(self, 'The options marker with a "*" are mandatory. Please fill them before generating a CCD file.', 'Error', wx.OK|wx.ICON_EXCLAMATION)
- # return False
- # return True
- ################################################
=== modified file 'src/cdg_main.py'
--- src/cdg_main.py 2012-07-19 22:21:28 +0000
+++ src/cdg_main.py 2012-07-20 00:25:17 +0000
@@ -1,10 +1,15 @@
# -*- coding: utf-8 -*-
# generated by wxGlade 0.6.4 on Tue Jul 17 15:12:08 2012
+import os
+import sys
+import uuid
+import locale
+import ConfigParser
+from xml.sax.saxutils import escape
+
import wx
-import cdg_extra
-import cdg_custom
-
+from wx.lib.wordwrap import wordwrap
# begin wxGlade: extracode
# end wxGlade
@@ -57,8 +62,8 @@
self.SetSize((800, 470))
self.label_date.SetToolTipString("Defalts to current day.")
self.datepicker_ctrl_date.SetMinSize((111, 28))
- self.choice_lang.SetItems(cdg_extra.get_lang_list())
- self.choice_lang.SetSelection(cdg_extra.get_lang_list().index('en-US') | 0)
+ self.choice_lang.SetItems(get_lang_list())
+ self.choice_lang.SetSelection(get_lang_list().index('en-US') | 0)
self.label_creator.SetToolTipString("Format emails as: Timothy W. Cook <timothywayne.cook@xxxxxxxxx>")
self.text_ctrl_creator.SetToolTipString("Format emails as: Timothy W. Cook <timothywayne.cook@xxxxxxxxx>")
self.text_ctrl_subject.SetToolTipString("Format emails as: Timothy W. Cook <timothywayne.cook@xxxxxxxxx>")
@@ -137,10 +142,317 @@
def init_things(self):
- self.c = cdg_custom.Config(self)
+ self.c = Config(self)
self.c.read_config()
self.c.set_panel_configs()
#self.button_save_config.Disable()
#self.Bind(wx.EVT_CLOSE, self.on_close_window)
# end of class MainDialog
+
+
+class Info(object):
+ def __init__(self):
+ self.title = ''
+ self.description = ''
+ self.creator = ''
+ self.creator_email = ''
+ self.contributor = ''
+
+ self.publisher = ''
+ self.subject = ''
+ self.source = ''
+ self.rights = ''
+ self.relation = ''
+ self.coverage = ''
+
+ self.language = ''
+
+ self.date = ''
+
+ self.ccd_id = "ccd_"+str(uuid.uuid4()).replace('-','_')
+
+ def get_info(self, title, description, date, creator, creator_email, contributor, language, publisher, subject, source, rights, relation, coverage):
+ self.title = title
+ self.description = description
+ self.creator = creator
+ self.creator_email = creator_email
+ self.contributor = contributor
+
+ self.publisher = publisher
+ self.subject = subject
+ self.source = source
+ self.rights = rights
+ self.relation = relation
+ self.coverage = coverage
+
+ self.language = language
+
+ self.date = date
+
+
+ def generate_file(self, path):
+
+
+ UUID_definition = "ct_"+str(uuid.uuid4()).replace('-','_')
+ UUID_string = "ct_"+str(uuid.uuid4()).replace('-','_')
+
+ schema = self.ccd_id + ".xsd"
+
+ contributors_formated = '<dc:contributor>' + \
+ '</dc:contributor>\n<dc:contributor>'.join([ escape(i).strip() for i in self.contributor.split(';')]) + \
+ '</dc:contributor>'
+
+ f = open(path+'/'+schema,'w')
+
+ f.write("""<?xml version="1.1" encoding="UTF-8"?>
+
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:mlhim2="http://www.mlhim.org/xmls/mlhim2/2_3_0"
+ elementFormDefault="qualified"
+ targetNamespace="http://www.mlhim.org/xmls/mlhim2/2_3_0">
+
+ <xs:annotation>
+ <xs:documentation source="http://www.mlhim.org" xml:lang="{language}">
+ This is a {title} Concept Constraint Definition schema file (CCD).
+
+ <rdf:RDF
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:dc= "http://purl.org/dc/elements/1.1/">
+
+ <rdf:Description rdf:about="http://www.hkcr.net/ccd/{ccd_id}">
+ <dc:title>{title}</dc:title>
+ <dc:creator>{creator} <{creator_email}> </dc:creator>
+ {contributors}
+ <dc:subject>{subject}</dc:subject>
+ <dc:source>{source}</dc:source>
+ <dc:rights>{rights}</dc:rights>
+ <dc:relation>{relation}</dc:relation>
+ <dc:coverage>{coverage}</dc:coverage>
+ <dc:type>{resource_type}</dc:type>
+ <dc:identifier>{identifier}</dc:identifier>
+ <dc:description>{description}</dc:description>
+ <dc:publisher>{publisher}</dc:publisher>
+ <dc:date>{date}</dc:date>
+ <dc:format>{resource_format}</dc:format>
+ <dc:language>{language}</dc:language>
+ </rdf:Description>
+
+ </rdf:RDF>
+
+ </xs:documentation>
+ </xs:annotation>
+
+ <xs:include schemaLocation="http://www.mlhim.org/xmls/mlhim2/2_3_0/mlhim2.xsd"/>
+
+ <xs:element name='CCD' type="mlhim2:{ccd_id}"/>
+ <xs:complexType name="{ccd_id}">
+ <xs:complexContent>
+ <xs:restriction base="mlhim2:CCDType">
+ <xs:sequence>
+ <xs:element name="definition" minOccurs="1" maxOccurs="1" type="mlhim2:{UUID_definition}"/>
+ </xs:sequence>
+ </xs:restriction>
+ </xs:complexContent>
+ </xs:complexType>
+
+</xs:schema>
+""".format(ccd_id = self.ccd_id,
+ UUID_definition = UUID_definition,
+ UUID_DvString = UUID_string,
+
+ title = escape(self.title),
+ description = escape(self.description),
+ date = self.date,
+ creator = escape(self.creator),
+ creator_email = escape(self.creator_email),
+ contributors = contributors_formated,
+ language = self.language,
+ publisher = escape(self.publisher),
+ subject = escape(self.subject),
+ source = escape(self.source),
+ rights = escape(self.rights),
+ relation = escape(self.relation),
+ coverage = escape(self.coverage),
+
+ resource_type = "MLHIM Concept Constraint Definition (CCD)",
+ resource_format = "text/xml",
+ identifier = self.ccd_id,
+
+ ))
+
+
+ f.write("<!-- Here are some UUIDs to use for complexType names:\n\n")
+
+ for x in range(0,10):
+ f.write("ct_"+str(uuid.uuid4()).replace('-','_')+"\n\n")
+
+ f.write("-->")
+
+ f.close()
+
+class Config(object):
+ def __init__(self, panel):
+ if sys.platform.startswith('linux'):
+ home = os.environ['HOME']
+ elif sys.platform.startswith('win'):
+ home = os.environ['HOMEDRIVE'] + '/' +os.environ['HOMEPATH']
+
+ else:
+ home = './'
+ self.configdir = home + '/.mlhim'
+ self.configname = self.configdir + '/' + 'metadata.cfg'
+ self.panel = panel
+
+ self.config = ConfigParser.SafeConfigParser({
+ 'title' : '',
+ 'description' : '',
+ 'creator' : '',
+ 'creator_email' : '',
+ 'contributor' : '',
+ 'publisher' : '',
+ 'subject' : '',
+ 'source' : '',
+ 'rights' : 'CC-BY http://creativecommons.org/licenses/by/3.0/',
+ 'relation' : 'None',
+ 'coverage' : 'Universal',
+ 'language' : '76',
+ 'choice_definition' : '0',
+ })
+
+ def read_config(self):
+ try:
+ if not self.config.read(self.configname):
+ self.make_config()
+ except:
+ self.save_config()
+
+
+ def make_config(self):
+ if not os.path.exists(self.configdir):
+ os.mkdir(self.configdir)
+ # with open(self.configname, 'wb') as configfile:
+ # self.config.write(configfile)
+
+ def save_config(self):
+ with open(self.configname, 'wb') as configfile:
+ configfile.write('# Concept Definition Generator Configuration\n# Do not edit the text to the left of the equal symbol (=)\n\n')
+ self.config.write(configfile)
+
+
+ def get_panel_configs(self):
+ self.config.set('DEFAULT', 'title', self.panel.text_ctrl_title.GetValue().encode('utf8'))
+ self.config.set('DEFAULT', 'description', self.panel.text_ctrl_description.GetValue().encode('utf8'))
+ self.config.set('DEFAULT', 'creator', self.panel.text_ctrl_creator.GetValue().encode('utf8'))
+ self.config.set('DEFAULT', 'creator_email', self.panel.text_ctrl_creator_email.GetValue().encode('utf8'))
+ self.config.set('DEFAULT', 'contributor', self.panel.text_ctrl_contributors.GetValue().encode('utf8'))
+
+ self.config.set('DEFAULT', 'publisher', self.panel.text_ctrl_publisher.GetValue().encode('utf8'))
+ self.config.set('DEFAULT', 'subject', self.panel.text_ctrl_subject.GetValue().encode('utf8'))
+ self.config.set('DEFAULT', 'source', self.panel.text_ctrl_source.GetValue().encode('utf8'))
+ self.config.set('DEFAULT', 'rights', self.panel.text_ctrl_rights.GetValue().encode('utf8'))
+ self.config.set('DEFAULT', 'relation', self.panel.text_ctrl_relation.GetValue().encode('utf8'))
+ self.config.set('DEFAULT', 'coverage', self.panel.text_ctrl_coverage.GetValue().encode('utf8'))
+
+ self.config.set('DEFAULT', 'language', str(self.panel.choice_lang.GetSelection()))
+
+ def set_panel_configs(self):
+ self.panel.text_ctrl_title.SetValue(self.config.get('DEFAULT', 'title'))
+ self.panel.text_ctrl_description.SetValue(self.config.get('DEFAULT', 'description'))
+ self.panel.text_ctrl_creator.SetValue(self.config.get('DEFAULT', 'creator'))
+ self.panel.text_ctrl_creator_email.SetValue(self.config.get('DEFAULT', 'creator_email'))
+ self.panel.text_ctrl_contributors.SetValue(self.config.get('DEFAULT', 'contributor'))
+
+ self.panel.text_ctrl_publisher.SetValue(self.config.get('DEFAULT', 'publisher'))
+ self.panel.text_ctrl_subject.SetValue(self.config.get('DEFAULT', 'subject'))
+ self.panel.text_ctrl_source.SetValue(self.config.get('DEFAULT', 'source'))
+ self.panel.text_ctrl_rights.SetValue(self.config.get('DEFAULT', 'rights'))
+ self.panel.text_ctrl_relation.SetValue(self.config.get('DEFAULT', 'relation'))
+ self.panel.text_ctrl_coverage.SetValue(self.config.get('DEFAULT', 'coverage'))
+
+ self.panel.choice_lang.SetSelection(int(self.config.get('DEFAULT', 'language')))
+
+
+
+###########################################################################
+# Misc functions - Maybe put them inside a class in the future
+###########################################################################
+def help_box(self):
+
+ dlg = wx.MessageDialog(self, """
+Emails are formatted as:
+Timothy W. Cook <timothywayne.cook@xxxxxxxxx>
+
+Separate multiple contributors with a semi-colon and format them as:
+Eduardo Cesar <xcesar@xxxxxxxxx>; Luciana Cavalini <lutricav@xxxxxxxxx>
+""",
+ 'Help',
+ wx.OK | wx.ICON_INFORMATION
+ #wx.YES_NO | wx.NO_DEFAULT | wx.CANCEL | wx.ICON_INFORMATION
+ )
+ dlg.ShowModal()
+ dlg.Destroy()
+
+
+def get_lang_list():
+ l = list(set(locale.locale_alias.keys()))
+ l.sort()
+ l2 = [i.replace('_','-')[0:3] + i[3:].upper() for i in l if ((len(i) < 6 and '_' in i) or len(i) == 2)]
+
+ return l2
+
+def get_path(self):
+ path = os.getcwd()
+
+ dlg = wx.DirDialog(self, "Choose a directory to put the generated files:",
+ path,
+ style=wx.DD_DEFAULT_STYLE
+ #| wx.DD_DIR_MUST_EXIST
+ #| wx.DD_CHANGE_DIR
+ )
+
+
+ if dlg.ShowModal() == wx.ID_OK:
+ path = dlg.GetPath()
+ else:
+ return None
+
+ dlg.Destroy()
+ return path
+
+
+def popup_message(self, msg, tag, icons):
+ dlg = wx.MessageDialog(self, msg, tag, icons)
+ result = dlg.ShowModal()
+ dlg.Destroy()
+ if result == wx.ID_OK:
+ return True
+ else:
+ return False
+
+def extract_info(self, info):
+ title = self.text_ctrl_title.GetValue().encode('utf8')
+ description = self.text_ctrl_description.GetValue().encode('utf8')
+ creator = self.text_ctrl_creator.GetValue().encode('utf8')
+ creator_email = self.text_ctrl_creator_email.GetValue().encode('utf8')
+ contributor = self.text_ctrl_contributors.GetValue().encode('utf8')
+
+ publisher = self.text_ctrl_publisher.GetValue().encode('utf8')
+ subject = self.text_ctrl_subject.GetValue().encode('utf8')
+ source = self.text_ctrl_source.GetValue().encode('utf8')
+ rights = self.text_ctrl_rights.GetValue().encode('utf8')
+ relation = self.text_ctrl_relation.GetValue().encode('utf8')
+ coverage = self.text_ctrl_coverage.GetValue().encode('utf8')
+
+ language = self.choice_lang.GetStringSelection()
+
+ tempo = self.datepicker_ctrl_date.GetValue()
+ date = '{Y}-{M}-{D:02}'.format(Y=tempo.GetYear(), M=tempo.GetMonth(), D=tempo.GetDay())
+
+ info.get_info(title, description, date, creator, creator_email, contributor, language, publisher, subject, source, rights, relation, coverage)
+ # # Test if the mandatary fields are with something
+ # if not (title and date and description and creator and subject and rights):
+ # popup_message(self, 'The options marker with a "*" are mandatory. Please fill them before generating a CCD file.', 'Error', wx.OK|wx.ICON_EXCLAMATION)
+ # return False
+ # return True
+ ################################################
=== modified file 'src/mlhim2.py'
--- src/mlhim2.py 2012-07-18 01:11:04 +0000
+++ src/mlhim2.py 2012-07-20 00:25:17 +0000
@@ -6,8 +6,6 @@
import gettext
import wx
-import cdg_extra
-import cdg_custom
from wx.lib.wordwrap import wordwrap
import cdg_main