From 67798b9b5a7e3c0908412652e364fc09a4e0660a Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sat, 26 Jun 2010 15:49:18 -0400 Subject: [PATCH] Moved prof_import/export down into sitecore/prof. Also moved doc/faculty.txt into the sitecore.prof doctring. --- doc/faculty.txt | 36 -------- sitecore/prof/__init__.py | 83 +++++++++++++++++++ .../{prof_export.py => prof/export_mysql.py} | 7 +- sitecore/{prof_import.py => prof/import.py} | 33 +------- 4 files changed, 90 insertions(+), 69 deletions(-) delete mode 100644 doc/faculty.txt create mode 100644 sitecore/prof/__init__.py rename sitecore/{prof_export.py => prof/export_mysql.py} (97%) rename sitecore/{prof_import.py => prof/import.py} (72%) diff --git a/doc/faculty.txt b/doc/faculty.txt deleted file mode 100644 index eb51288..0000000 --- a/doc/faculty.txt +++ /dev/null @@ -1,36 +0,0 @@ -Sitecore Faculty Profile Corresponding Information - -Faculty Information -------------------- -Degrees* Degrees Earned (i.e. Dr., PhD) -College* University Graduated From -Program Area Within Department (i.e. Anthropology) -Office* Office Location -Office Hours (If applicable) -Specialization* Research Areas/Specialization -Publications Publications Listing (If applicable) -Professional Society (If applicable) -Academic Distinctions (If applicable) -Research Interests (Please use "Specialization" Field) -Personal Site Website Address (If applicable) - -Personal Profile ----------------- -Title* Professional Title (i.e. Director of Publication Management) -First Name* First Name / Middle Name -Last Name* Last Name -Bio Brief Bio/Profile/Blurb -Short Bio Presentations (If applicable) -Headshot* Photograph – Size should be width: 125px height: 150px -Email* Email -Phone* Phone # ‐ Please use this format: (111) 111‐1111 -Fax Lab Name, Lab Phone (If applicable, please use "Lab Name, Lab Phone" format) -CV Resume - -* field required. - -If a basic text field (a field with no "editor") has more than one -item in it then separate the items with a comma. For example: If a -faculty member has more than one title, then list their titles like -this: Professor of Communication, Director of Publication Management, -Yearbook Advisor, etc. diff --git a/sitecore/prof/__init__.py b/sitecore/prof/__init__.py new file mode 100644 index 0000000..fd91f36 --- /dev/null +++ b/sitecore/prof/__init__.py @@ -0,0 +1,83 @@ +#!/usr/bin/env python +# Copyright (C) 2010 W. Trevor King +# +# This file is part of SiteCorePy. +# +# SiteCorePy is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation, either version 2 of the License, or (at your +# option) any later version. +# +# SiteCorePy is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with SiteCorePy. If not, see . + +""" +Sitecore Faculty Profile Corresponding Information + +Faculty Information +------------------- +Degrees* Degrees Earned (i.e. Dr., PhD) +College* University Graduated From +Program Area Within Department (i.e. Anthropology) +Office* Office Location +Office Hours (If applicable) +Specialization* Research Areas/Specialization +Publications Publications Listing (If applicable) +Professional Society (If applicable) +Academic Distinctions (If applicable) +Research Interests (Please use "Specialization" Field) +Personal Site Website Address (If applicable) + +Personal Profile +---------------- +Title* Professional Title (i.e. Director of Publication Management) +First Name* First Name / Middle Name +Last Name* Last Name +Bio Brief Bio/Profile/Blurb +Short Bio Presentations (If applicable) +Headshot* Photograph – Size should be width: 125px height: 150px +Email* Email +Phone* Phone # ‐ Please use this format: (111) 111‐1111 +Fax Lab Name, Lab Phone (If applicable, please use "Lab Name, Lab Phone" format) +CV Resume + +* field required. + +If a basic text field (a field with no "editor") has more than one +item in it then separate the items with a comma. For example: If a +faculty member has more than one title, then list their titles like +this: Professor of Communication, Director of Publication Management, +Yearbook Advisor, etc. +""" + +class AttributeHolder (object): + self.fields = [] + def __init__(self, *args, **kwargs): + for field in self.fields: + setattr(self, field, None) + for field,arg in zip(self.fields, args): + setattr(self, field, arg) + for field,value in kwargs.items(): + assert field in self.fields, '%s not in %s' % (field, self.fields) + setattr(self, field, value) + + +class Name (AttributeHolder): + self.fields = ['first_middle', 'last'] + +class Graduation (AttributeHolder): + self.fields = ['college', 'title', 'year'] + +class Contact (AttributeHolder): + self.fields = ['office', 'website', 'phone', 'lab', 'lab_phone'] + +class Bio (AttributeHolder): + self.fields = ['specialization', 'publications', 'profile', 'cv'] + +class Professor (object): + self.fields = ['name', 'graduations', 'contact', 'bio'] diff --git a/sitecore/prof_export.py b/sitecore/prof/export_mysql.py similarity index 97% rename from sitecore/prof_export.py rename to sitecore/prof/export_mysql.py index 0de8037..88871de 100644 --- a/sitecore/prof_export.py +++ b/sitecore/prof/export_mysql.py @@ -26,9 +26,10 @@ import getpass import logging import MySQLdb +import yaml -from . import get_logger -from .prof_import import Name, Graduation, Contact, Bio, Professor +from .. import get_logger +from . import Name, Graduation, Contact, Bio, Professor class SimpleDB (object): @@ -158,7 +159,7 @@ if __name__ == '__main__': Where PROF_FILE is the output YAML file receiving professor data. Example: - ./sitecore/prof_export.py profs.yaml + ./sitecore/prof/export_mysql.py profs.yaml """ p = optparse.OptionParser(usage) p.add_option('-d', '--database', metavar='NAME', dest='database', diff --git a/sitecore/prof_import.py b/sitecore/prof/import.py similarity index 72% rename from sitecore/prof_import.py rename to sitecore/prof/import.py index fb7ed00..d9110c8 100644 --- a/sitecore/prof_import.py +++ b/sitecore/prof/import.py @@ -23,37 +23,10 @@ Professors will be created in: """ from selenium.common.exceptions import NoSuchElementException - -from . import SiteCoreConnection import yaml - -class AttributeHolder (object): - self.fields = [] - def __init__(self, *args, **kwargs): - for field in self.fields: - setattr(self, field, None) - for field,arg in zip(self.fields, args): - setattr(self, field, arg) - for field,value in kwargs.items(): - assert field in self.fields, '%s not in %s' % (field, self.fields) - setattr(self, field, value) - - -class Name (AttributeHolder): - self.fields = ['first_middle', 'last'] - -class Graduation (AttributeHolder): - self.fields = ['college', 'title', 'year'] - -class Contact (AttributeHolder): - self.fields = ['office', 'website', 'phone', 'lab', 'lab_phone'] - -class Bio (AttributeHolder): - self.fields = ['specialization', 'publications', 'profile', 'cv'] - -class Professor (object): - self.fields = ['name', 'graduations', 'contact', 'bio'] +from .. import SiteCoreConnection +from . import Name, Graduation, Contact, Bio, Professor class ProfessorAdder (object): @@ -83,7 +56,7 @@ Example setup before running: Xvfb :99 > /dev/null 2>&1 & export DISPLAY=:99 java -jar selenium-server-1.0.2-SNAPSHOT-standalone.jar > /dev/null 2>&1 & - ./sitecore/prof_import.py profs.yaml + ./sitecore/prof/import.py profs.yaml """ p = optparse.OptionParser(usage) p.add_option('-u', '--url', metavar='URL', dest='url', -- 2.26.2