示例#1
0
def create_note(store, path, notebook):
    """Create a note from the content in a local file
    """
    ext = utils.get_file_ext(path)
    processor_cls = note_processors.get(ext)
    processor = processor_cls(path)
    note = Note()
    note.title = processor.get_title()
    note.content = processor.get_content()
    attributes = NoteAttributes()
    attributes.sourceURL = utils.path_to_source_url(notebook, path)
    note.attributes = attributes
    note.notebookGuid = notebook.guid
    try:
        return store.createNote(dev_token, note)
    except EDAMUserException as e:
        evernote_api_error(e, note)
示例#2
0
文件: main.py 项目: yejianye/eversync
def create_note(store, path, notebook):
    """Create a note from the content in a local file
    """
    ext = utils.get_file_ext(path)
    processor_cls = note_processors.get(ext)
    processor = processor_cls(path)
    note = Note()
    note.title = processor.get_title()
    note.content = processor.get_content()
    attributes = NoteAttributes()
    attributes.sourceURL = utils.path_to_source_url(notebook, path)
    note.attributes = attributes
    note.notebookGuid = notebook.guid
    try:
        return store.createNote(dev_token, note)
    except EDAMUserException as e:
        evernote_api_error(e, note)
 def test_full_metadata(self):
     note = Note()
     note.title = "test title"
     attributes = NoteAttributes()
     note.attributes = attributes
     attributes.sourceURL = "https://testdomain/some/path"
     attributes.latitude = 1
     attributes.source = "testsource"
     attributes.placeName = "testplace"
     attributes.contentClass = "testclass"
     featuredict = {}
     features.add_metadata_features(featuredict, note)
     expected_keys = ("META-TITLETOKEN-test", "META-TITLETOKEN-title",
                      "META-URL-testdomain", "META-HASURL",
                      "META-HASLOCATION", "META-SOURCE-testsource",
                      "META-PLACE-testplace", "META-CONTENTCLASS-testclass")
     expected = dict.fromkeys(expected_keys, 1)
     self.assertEqual(featuredict, expected)
示例#4
0
     content=
     '<!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd"><en-note><en-todo/>test<br/></en-note>',
     tagNames=None,
     updateSequenceNum=1311,
     tagGuids=['43bd1db1-9c67-42f2-ae9f-7932f8f89d5d'],
     active=True,
     attributes=NoteAttributes(lastEditorId=None,
                               placeName='new',
                               sourceURL=None,
                               classifications=None,
                               creatorId=None,
                               author=None,
                               reminderTime=None,
                               altitude=None,
                               reminderOrder=None,
                               shareDate=None,
                               reminderDoneTime=None,
                               longitude=None,
                               lastEditedBy=None,
                               source=None,
                               applicationData=None,
                               sourceApplication='LogisticsApp',
                               latitude=None,
                               contentClass=None,
                               subjectDate=None),
     guid='da4b312a-7486-4dab-833f-914c7653050e',
     resources=None),
 Note(
     contentHash='ynA\xf6s\xad\\\xc96q\x8f\x12\x9d\xc9\x93\x9a',
     updated=1519361101000,
     created=1519361101000,
示例#5
0
            mime="image/png",
            width=403,
            height=613,
            active=True,
            recognition=Data(bodyHash=b"1234", size=4332, body=b"1234"),
            data=Data(bodyHash=b"1234", size=58387, body=b"1234"),
            updateSequenceNum=6461,
            attributes=ResourceAttributes(
                fileName="test.png",
                attachment=True,
            ),
        )
    ],
    attributes=NoteAttributes(
        author="*****@*****.**",
        source="desktop.win",
        sourceURL="https://www.example.com/page?category=blog&post_id=123",
        sourceApplication="evernote.win32",
    ),
    tagNames=["test1", "test2"],
)

expected = """  <note>
    <title>Test Title</title>
    <created>20210209T203437Z</created>
    <updated>20210407T164325Z</updated>
    <tag>test1</tag>
    <tag>test2</tag>
    <note-attributes>
      <author>[email protected]</author>
      <source>desktop.win</source>
      <source-url>https://www.example.com/page?category=blog&amp;post_id=123</source-url>