josh-gmail-backup 0.104
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/gmail-backup +6 -0
- data/bin/gmail-backup-gui +6 -0
- data/gmail-backup-gui.pyo +0 -0
- data/gmail-backup-gui.sh +2 -0
- data/gmail-backup.gemspec +36 -0
- data/gmail-backup.pyo +0 -0
- data/gmail-backup.sh +2 -0
- data/gmb.gif +0 -0
- data/gmb.ico +0 -0
- data/gmb.pyo +0 -0
- data/svc/LICENSE.TXT +12 -0
- data/svc/__init__.py +0 -0
- data/svc/egg.py +166 -0
- data/svc/map.py +123 -0
- data/svc/osutils.py +67 -0
- data/svc/registry.py +171 -0
- data/svc/retrans.py +225 -0
- data/svc/scripting/__init__.py +1461 -0
- data/svc/scripting/conversions.py +157 -0
- data/svc/scripting/externals.py +580 -0
- data/svc/scripting/extractors.py +361 -0
- data/svc/scripting/help.py +173 -0
- data/svc/template.py +76 -0
- data/svc/utils.py +261 -0
- metadata +77 -0
data/svc/utils.py
ADDED
@@ -0,0 +1,261 @@
|
|
1
|
+
# Copyright (C) 2008 Jan Svec and Filip Jurcicek
|
2
|
+
#
|
3
|
+
# YOU USE THIS TOOL ON YOUR OWN RISK!
|
4
|
+
#
|
5
|
+
# email: info@gmail-backup.com
|
6
|
+
#
|
7
|
+
#
|
8
|
+
# Disclaimer of Warranty
|
9
|
+
# ----------------------
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, licensor provides
|
12
|
+
# this tool (and each contributor provides its contributions) on an "AS IS"
|
13
|
+
# BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
14
|
+
# implied, including, without limitation, any warranties or conditions of
|
15
|
+
# TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR
|
16
|
+
# PURPOSE. You are solely responsible for determining the appropriateness of
|
17
|
+
# using this work and assume any risks associated with your exercise of
|
18
|
+
# permissions under this license.
|
19
|
+
|
20
|
+
import sys
|
21
|
+
import codecs
|
22
|
+
from types import StringTypes
|
23
|
+
from inspect import isroutine
|
24
|
+
|
25
|
+
class sym(object):
|
26
|
+
def __init__(self, s):
|
27
|
+
self.__s = s
|
28
|
+
|
29
|
+
def __hash__(self):
|
30
|
+
return hash(self.__s)
|
31
|
+
|
32
|
+
def __eq__(self, other):
|
33
|
+
return self.__s == other
|
34
|
+
|
35
|
+
def __str__(self):
|
36
|
+
return str(self.__s)
|
37
|
+
|
38
|
+
def __repr__(self):
|
39
|
+
return str(self.__s)
|
40
|
+
|
41
|
+
def isstr(obj):
|
42
|
+
"""Return True if `obj` is string (Unicode or 8-bit)
|
43
|
+
|
44
|
+
:RType: bool
|
45
|
+
"""
|
46
|
+
return isinstance(obj, StringTypes)
|
47
|
+
|
48
|
+
def issequence(obj):
|
49
|
+
"""Return True if `obj` is sequence, but not string
|
50
|
+
|
51
|
+
:RType: bool
|
52
|
+
"""
|
53
|
+
if isstr(obj):
|
54
|
+
return False
|
55
|
+
else:
|
56
|
+
try:
|
57
|
+
len(obj)
|
58
|
+
return True
|
59
|
+
except TypeError:
|
60
|
+
return False
|
61
|
+
|
62
|
+
def partial(fn, *cargs, **ckwargs):
|
63
|
+
def partial_fn(*fargs, **fkwargs):
|
64
|
+
d = ckwargs.copy()
|
65
|
+
d.update(fkwargs)
|
66
|
+
return fn(*(cargs + fargs), **d)
|
67
|
+
return partial_fn
|
68
|
+
|
69
|
+
def strnumber(obj):
|
70
|
+
"""Return string representation of `obj`.
|
71
|
+
|
72
|
+
If `obj` is float representing integer number (eg. 2.0), it will return
|
73
|
+
integer number (eg. '2'). Otherwise `obj` is converted into string using
|
74
|
+
``str(obj)``.
|
75
|
+
|
76
|
+
:RType: str
|
77
|
+
"""
|
78
|
+
try:
|
79
|
+
if int(obj) == float(obj):
|
80
|
+
obj = int(obj)
|
81
|
+
except (ValueError, TypeError):
|
82
|
+
pass
|
83
|
+
return str(obj)
|
84
|
+
|
85
|
+
def strcomma(seq, comma=', '):
|
86
|
+
"""Return string representation of sequence `seq`
|
87
|
+
|
88
|
+
Objects of sequence are converted into strings using ``str(obj)``.
|
89
|
+
Resulting sequence is then joint using `comma` string. If `comma` is not
|
90
|
+
supplied, ', ' will be used.
|
91
|
+
|
92
|
+
:RType: str
|
93
|
+
"""
|
94
|
+
return comma.join(str(o) for o in seq)
|
95
|
+
|
96
|
+
def cartezian(*vectors):
|
97
|
+
"""Compute Cartesian product of passed arguments
|
98
|
+
"""
|
99
|
+
ret = ret_old = [(v,) for v in vectors[0]]
|
100
|
+
for vec in vectors[1:]:
|
101
|
+
ret = []
|
102
|
+
for v in vec:
|
103
|
+
for r in ret_old:
|
104
|
+
ret.append(r+(v,))
|
105
|
+
ret_old = ret
|
106
|
+
return ret
|
107
|
+
|
108
|
+
def iterslice(sl, length=None):
|
109
|
+
"""Return xrange() created from slice object `sl`
|
110
|
+
"""
|
111
|
+
if sl.start is None:
|
112
|
+
start = 0
|
113
|
+
else:
|
114
|
+
start = sl.start
|
115
|
+
if sl.stop is None:
|
116
|
+
if length is None:
|
117
|
+
raise ValueError("If slice.stop is None, you must supply length arg.")
|
118
|
+
else:
|
119
|
+
stop = length
|
120
|
+
else:
|
121
|
+
stop = sl.stop
|
122
|
+
if sl.step is None:
|
123
|
+
step = 1
|
124
|
+
else:
|
125
|
+
step = sl.step
|
126
|
+
return xrange(start, stop, step)
|
127
|
+
|
128
|
+
def seqIntoDict(seq, format):
|
129
|
+
_posOptsDict = {}
|
130
|
+
_negativeAfter = sys.maxint
|
131
|
+
have_ellipsis = False
|
132
|
+
i = 0
|
133
|
+
if format.count(Ellipsis) > 1:
|
134
|
+
raise ValueError("Ellipsis must be used only once")
|
135
|
+
while i < len(format):
|
136
|
+
opt_name = format[i]
|
137
|
+
if opt_name == Ellipsis:
|
138
|
+
have_ellipsis = True
|
139
|
+
if i == 0:
|
140
|
+
raise ValueError("Ellipsis must be after option name")
|
141
|
+
j = -1
|
142
|
+
while True:
|
143
|
+
opt_name = format[j]
|
144
|
+
if opt_name == Ellipsis:
|
145
|
+
break
|
146
|
+
_posOptsDict[opt_name] = j
|
147
|
+
j -= 1
|
148
|
+
if j+1 == 0:
|
149
|
+
# slice [i-1:] != [i-1:0]
|
150
|
+
_posOptsDict[format[i-1]] = slice(i-1, None)
|
151
|
+
else:
|
152
|
+
# slice [i-1:j+1]
|
153
|
+
_posOptsDict[format[i-1]] = slice(i-1, j+1)
|
154
|
+
# Negative indices can be used if there was enough arguments to
|
155
|
+
# fill options preceding Ellipsis
|
156
|
+
_negativeAfter = len(_posOptsDict)-1
|
157
|
+
break
|
158
|
+
_posOptsDict[opt_name] = i
|
159
|
+
i += 1
|
160
|
+
|
161
|
+
# Is there enough positional arguments to use negative indices?
|
162
|
+
use_negative = ( len(seq) >= _negativeAfter )
|
163
|
+
ret = {}
|
164
|
+
|
165
|
+
for opt_name, getter in _posOptsDict.iteritems():
|
166
|
+
try:
|
167
|
+
if not isinstance(getter, slice):
|
168
|
+
# Skip negative indices if there wasn't enough positional
|
169
|
+
# arguments
|
170
|
+
if getter < 0 and not use_negative:
|
171
|
+
continue
|
172
|
+
value = seq[getter]
|
173
|
+
if not isinstance(getter, slice):
|
174
|
+
ret[opt_name] = value
|
175
|
+
elif value:
|
176
|
+
ret[opt_name] = value
|
177
|
+
except IndexError:
|
178
|
+
# Option is not specified
|
179
|
+
pass
|
180
|
+
return ret
|
181
|
+
|
182
|
+
def linspace(start, stop, count):
|
183
|
+
if stop < 0:
|
184
|
+
(start, stop) = (start+stop, start-stop)
|
185
|
+
step = (stop - start) / float(count-1)
|
186
|
+
return [start+i*step for i in range(count)]
|
187
|
+
|
188
|
+
def linrange(start, stop, step):
|
189
|
+
if stop < 0:
|
190
|
+
(start, stop) = (start+stop, start-stop)
|
191
|
+
count = int(round((stop - start) / step) + 1)
|
192
|
+
return [start+i*step for i in range(count)]
|
193
|
+
|
194
|
+
unique_value = ['unique_value']
|
195
|
+
|
196
|
+
def all_same(seq, default=unique_value):
|
197
|
+
for i in seq:
|
198
|
+
if default is unique_value:
|
199
|
+
default = i
|
200
|
+
if i != default:
|
201
|
+
return False
|
202
|
+
else:
|
203
|
+
return True
|
204
|
+
|
205
|
+
def _defaultZero():
|
206
|
+
return 0
|
207
|
+
|
208
|
+
class ADict(dict):
|
209
|
+
'Accumulator dictionary'
|
210
|
+
def __init__(self, source={}, default=_defaultZero, **kwargs):
|
211
|
+
super(ADict, self).__init__(source, **kwargs)
|
212
|
+
self._default = default
|
213
|
+
|
214
|
+
def __getitem__(self, key):
|
215
|
+
if key not in self:
|
216
|
+
ret = self._default()
|
217
|
+
try:
|
218
|
+
hash(ret)
|
219
|
+
except TypeError:
|
220
|
+
# Store it
|
221
|
+
self[key] = ret
|
222
|
+
return ret
|
223
|
+
else:
|
224
|
+
return super(ADict, self).__getitem__(key)
|
225
|
+
|
226
|
+
def __add__(self, other):
|
227
|
+
new = self.__class__(self)
|
228
|
+
for key, value in other.iteritems():
|
229
|
+
new[key] += value
|
230
|
+
return new
|
231
|
+
|
232
|
+
def sum(self):
|
233
|
+
return sum(self.values())
|
234
|
+
|
235
|
+
def writeToFile(self, fn, key=None, format='%d', encoding='utf-8'):
|
236
|
+
fw = codecs.open(fn, 'w', encoding)
|
237
|
+
try:
|
238
|
+
for key, count in sorted(self.iteritems(), key=key):
|
239
|
+
if not issequence(key):
|
240
|
+
key = [key]
|
241
|
+
string = u'\t'.join(unicode(i) for i in key)
|
242
|
+
value = format % count
|
243
|
+
fw.write('%s\t%s\n' % (string, value))
|
244
|
+
finally:
|
245
|
+
fw.close()
|
246
|
+
|
247
|
+
@classmethod
|
248
|
+
def readFromFile(cls, fn, format=int, encoding='utf-8'):
|
249
|
+
fr = codecs.open(fn, 'r', encoding)
|
250
|
+
try:
|
251
|
+
new = cls()
|
252
|
+
for line in fr:
|
253
|
+
items = line.split()
|
254
|
+
value = format(items[-1])
|
255
|
+
key = tuple(items[:-1])
|
256
|
+
new[key] += value
|
257
|
+
return new
|
258
|
+
finally:
|
259
|
+
fr.close()
|
260
|
+
|
261
|
+
|
metadata
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: josh-gmail-backup
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: "0.104"
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- "Jan \xC5\xA0vec"
|
8
|
+
- "Filip Jur\xC4\x8D\xC3\xAD\xC4\x8Dek"
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2008-10-15 00:00:00 -07:00
|
14
|
+
default_executable:
|
15
|
+
dependencies: []
|
16
|
+
|
17
|
+
description:
|
18
|
+
email: info@gmail-backup.com
|
19
|
+
executables:
|
20
|
+
- gmail-backup
|
21
|
+
- gmail-backup-gui
|
22
|
+
extensions: []
|
23
|
+
|
24
|
+
extra_rdoc_files: []
|
25
|
+
|
26
|
+
files:
|
27
|
+
- gmail-backup-gui.pyo
|
28
|
+
- gmail-backup-gui.sh
|
29
|
+
- gmail-backup.gemspec
|
30
|
+
- gmail-backup.pyo
|
31
|
+
- gmail-backup.sh
|
32
|
+
- gmb.gif
|
33
|
+
- gmb.ico
|
34
|
+
- gmb.pyo
|
35
|
+
- svc/__init__.py
|
36
|
+
- svc/egg.py
|
37
|
+
- svc/LICENSE.TXT
|
38
|
+
- svc/map.py
|
39
|
+
- svc/osutils.py
|
40
|
+
- svc/registry.py
|
41
|
+
- svc/retrans.py
|
42
|
+
- svc/scripting
|
43
|
+
- svc/scripting/__init__.py
|
44
|
+
- svc/scripting/conversions.py
|
45
|
+
- svc/scripting/externals.py
|
46
|
+
- svc/scripting/extractors.py
|
47
|
+
- svc/scripting/help.py
|
48
|
+
- svc/template.py
|
49
|
+
- svc/utils.py
|
50
|
+
has_rdoc: false
|
51
|
+
homepage: http://www.gmail-backup.com/
|
52
|
+
post_install_message:
|
53
|
+
rdoc_options: []
|
54
|
+
|
55
|
+
require_paths:
|
56
|
+
- lib
|
57
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: "0"
|
62
|
+
version:
|
63
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: "0"
|
68
|
+
version:
|
69
|
+
requirements: []
|
70
|
+
|
71
|
+
rubyforge_project:
|
72
|
+
rubygems_version: 1.2.0
|
73
|
+
signing_key:
|
74
|
+
specification_version: 2
|
75
|
+
summary: The ultimate one-click solution for doing backups of your GMail account
|
76
|
+
test_files: []
|
77
|
+
|