Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 2 commits
  • 3 files changed
  • 0 comments
  • 1 contributor
57  fluidity/boxidate.py
@@ -14,6 +14,7 @@
14 14
 import datetime
15 15
 import json
16 16
 import os
  17
+import pathlib
17 18
 import pickle
18 19
 import shutil
19 20
 import string  # IGNORE:W0402  # the string module is not deprecated!
@@ -32,6 +33,7 @@
32 33
 from fluidity import defs
33 34
 from fluidity import dbus_misc
34 35
 from fluidity import gio_fml
  36
+from fluidity import slider
35 37
 
36 38
 
37 39
 INBOXES = ()
@@ -54,7 +56,15 @@ def consolidate():
54 56
         else:
55 57
             inboxes.append(MountableInbox(ibx))
56 58
 
57  
-    inboxes.extend((RESTInbox(), TomboyInbox()))
  59
+    inboxes.extend((
  60
+        # CONFIG FOR WHICH INBOXES GET USED AND WHICH DON'T
  61
+        # terrible place for it, but this is the kind of thing
  62
+        # that's going away when I finally get around to 
  63
+        # refactoring all this
  64
+#        RESTInbox(), 
  65
+        DropboxInbox(),
  66
+        TomboyInbox(),  # this should probably always be the last one.
  67
+    ))
58 68
     for i in inboxes:
59 69
         i.consolidate()
60 70
 
@@ -234,7 +244,9 @@ def build_aggregate_note(self, notelist):
234 244
         el = len(self.TB_CONTENT_START)
235 245
         for n in notelist:
236 246
             n = os.path.join(self.MAIN_INBOX, n)
237  
-            c = open(n, 'r').read()
  247
+            opened = open(n, 'r')
  248
+            c = opened.read()
  249
+            opened.close()
238 250
             c_begin = c.find(self.TB_CONTENT_START) + el
239 251
             c_end = c.find(self.TB_CONTENT_END)
240 252
             aggregate += c[c_begin:c_end] + self.PADDING
@@ -324,6 +336,37 @@ def _horrible_hack_to_get_NV_inbox(self):
324 336
         return personal_content
325 337
 
326 338
 
  339
+class DropboxInbox(Inbox):
  340
+
  341
+    NOTE_GLOB = 'inbox_note*.protobytes'
  342
+
  343
+    def consolidate(self):
  344
+        for note_path in defs.DROPBOX_INBOX_PATH.glob(DropboxInbox.NOTE_GLOB):
  345
+            self._process_android_inbox_note(note_path)
  346
+        # now handle the remaining files.
  347
+        for path in defs.DROPBOX_INBOX_PATH.glob('*'):
  348
+            # leave dotfiles alone, for stuff like dropsync
  349
+            if not str(path).startswith('.'):
  350
+                self._process_android_inbox_note(note_path)
  351
+    
  352
+    def _process_regular_file(self, path):
  353
+        print("Processing regular file:", path)
  354
+        shutil.move(str(path), defs.INBOX_FOLDER)
  355
+
  356
+    def _process_android_inbox_note(self, note_path):
  357
+        print("Processing note:", note_path)
  358
+        abs_path = str(note_path.absolute())
  359
+        with open(abs_path, 'r') as notefile:
  360
+            note_text = notefile.read()
  361
+        
  362
+        # the android inbox app takes no 'details' info yet.
  363
+        slider.create_inbox_note(note_text, "")
  364
+        
  365
+        # we're done with the file, ditch it.
  366
+        gf = gio.File(abs_path)
  367
+        gf.trash()
  368
+
  369
+
327 370
 class BoxidatorOld(object):
328 371
     """Consolidate my inboxes, including content from an external Tomboy note."""
329 372
 
@@ -573,3 +616,13 @@ def _convert_xml(element):
573 616
 # #        sftp.put(to_upload, remote_path + basename)
574 617
 # #        sftp.close()
575 618
 #===================================================================================
  619
+
  620
+
  621
+def main():
  622
+    di = DropboxInbox()
  623
+    di.consolidate()
  624
+
  625
+
  626
+if __name__ == '__main__':
  627
+    main()
  628
+
7  fluidity/defs.py
@@ -93,6 +93,7 @@ def _get_read_review_path():
93 93
 
94 94
 ### PATHS ###
95 95
 HOME_DIR = os.path.expanduser("~")
  96
+HOME_PATH = pathlib.Path(HOME_DIR)
96 97
 APP_DATA_PATH = _find_app_data_path()
97 98
 USER_DATA_PATH = BaseDirectory.save_data_path("fluidity")
98 99
 LOG_FILE_PATH = os.path.join(USER_DATA_PATH, 'fluidity_debug.log')
@@ -103,7 +104,11 @@ def _get_read_review_path():
103 104
 BACKUPS_PATH = os.path.join(USER_DATA_PATH, "backups")
104 105
 ARCHIVED_SINGLETONS_FNAME = 'archived_singletons{0}.pkl'
105 106
 
106  
-HACK_HACK_HACK_DROPBOX_PATH = pathlib.Path(HOME_DIR, "Dropbox", "Fluidity")
  107
+DROPBOX_PATH = pathlib.Path(HOME_PATH, 'Dropbox')
  108
+DROPBOX_INBOX_PATH = pathlib.Path(DROPBOX_PATH, 'Inbox')
  109
+
  110
+
  111
+HACK_HACK_HACK_DROPBOX_PATH = pathlib.Path(DROPBOX_PATH, "Fluidity")
107 112
 
108 113
 # PROJECT SUPPORT FILE PATHS
109 114
 READ_REVIEW_PATH = _get_read_review_path()
19  fluidity/slider.py
@@ -35,6 +35,16 @@
35 35
 from fluidity.managers import DataManager
36 36
 
37 37
 
  38
+def create_inbox_note(summary, details):
  39
+    """Create an inbox note with the usual path and format."""
  40
+    note = {'summary': summary, 'details': details}
  41
+    file_name = (note['summary'][:50].replace(os.sep, '') + 
  42
+                 str(time.time()) + "-note.pkl")
  43
+    file_path = os.path.join(defs.NOTE_SLIDER_FOLDER, file_name)
  44
+    with open(file_path, 'wb') as pickle_file:
  45
+        pickle.dump(note, pickle_file, pickle.HIGHEST_PROTOCOL)
  46
+
  47
+
38 48
 class Slider(object):
39 49
 
40 50
     def __init__(self, separate_process=False):
@@ -78,13 +88,8 @@ def _autocomplete_context(self, widget):
78 88
         widget.set_text(context)
79 89
 
80 90
     def _create_inbox_note(self):
81  
-        note = {'summary': self.summary_w.get_text(),
82  
-                'details': self.note_details_w.get_buffer().props.text}
83  
-        file_name = (note['summary'][:50].replace(os.sep, '') +
84  
-                     str(time.time()) + "-note.pkl")
85  
-        file_path = os.path.join(defs.NOTE_SLIDER_FOLDER, file_name)
86  
-        with open(file_path, 'wb') as pickle_file:
87  
-            pickle.dump(note, pickle_file, pickle.HIGHEST_PROTOCOL)
  91
+        create_inbox_note(self.summary_w.get_text(), 
  92
+                          self.note_details_w.get_buffer().props.text)
88 93
         self._quit()
89 94
 
90 95
     def _create_incoming_na(self, na):

No commit comments for this range

Something went wrong with that request. Please try again.