/
ljcs.py
executable file
·52 lines (36 loc) · 1.59 KB
/
ljcs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#! /usr/bin/python
# -*- coding: utf-8 -*-
from livejournal import LiveJournal, Config, evalue, list2mask
from livejournal.config import std_parser
parser = std_parser (usage = '%prog [options]')
parser.add_option ('-F', '--from',
action = 'store', type = 'string', dest = 'sfrom', default = 'public',
help = 'what security level change', metavar = 'SECURITY')
parser.add_option ('-T', '--to',
action = 'store', type = 'string', dest = 'sto', default = 'friends',
help = 'what security level change', metavar = 'SECURITY')
options, args = parser.parse_args ()
config = Config ()
config.load (evalue ('~/.ljrc', options.config))
server = getattr (config, options.server)
username = evalue (server.username, options.username)
password = evalue (server.password, options.password)
if username is None or password is None:
print "You must provide both user name and password"
sys.exit (2)
lj = LiveJournal (config.misc.version)
info = lj.login (username, password)
sfrom = list2mask (options.sfrom, info.friendgroups)
sto = list2mask (options.sto, info.friendgroups)
print 'We are about to change from "%s" to "%s"' % (sfrom, sto)
if 0:
daycounts = lj.getdaycounts ()['daycounts']
for day in daycounts:
# print day['date'], '->', day['count']
events = lj.getevents ('day', day['date'])
for event in events:
security = getattr (event, 'security', 'public')
if security == 'usemask':
print security, event.allowmask
else:
print security