2 # Copyright (C) 2010 W. Trevor King <wking@drexel.edu>
4 # This file is part of SiteCorePy.
6 # SiteCorePy is free software; you can redistribute it and/or modify it
7 # under the terms of the GNU General Public License as published by the
8 # Free Software Foundation, either version 2 of the License, or (at your
9 # option) any later version.
11 # SiteCorePy is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with SiteCorePy. If not, see <http://www.gnu.org/licenses/>.
19 """Move Professors from YAML -> Sitecore.
21 Professors will be created in:
22 Content -> Drexel -> ? -> physics -> ?
25 from selenium.common.exceptions import NoSuchElementException
28 from .. import SiteCoreConnection
29 from . import Name, Graduation, Contact, Bio, Professor
32 class ProfessorAdder (object):
33 """See doc/faculty.txt for Drexel's field/format policy.
35 def __init__(self, sitecore_connection):
36 self.s = sitecore_connection
39 s.expand_nav_section('Media Library')
40 s.expand_nav_section('Images')
41 s.expand_nav_section('physics')
42 s.expand_nav_section('headshots')
44 def __call__(self, prof):
46 s.open_nav_section(raw_name)
51 usage = """%prog [options] PROF_FILE
53 Where PROF_FILE is a YAML file containing professor data.
55 Example setup before running:
56 Xvfb :99 > /dev/null 2>&1 &
58 java -jar selenium-server-1.0.2-SNAPSHOT-standalone.jar > /dev/null 2>&1 &
59 ./sc prof-import profs.yaml
61 p = optparse.OptionParser(usage)
62 p.add_option('-u', '--url', metavar='URL', dest='url',
63 help='set the website URL (%default)',
64 default='https://webedit.drexel.edu/sitecore/login')
65 p.add_option('-v', '--verbose', dest='verbose', action='count',
66 help='increment verbosity (%default)',
69 options,args = p.parse_args(argv)
71 profs = yaml.load(prof_file)
73 s = SiteCoreConnection(options.url, options.verbose)
80 a.aadd_profs(s, profs)