Coder Social home page Coder Social logo

wfapi's Introduction

wfapi

Workflowy's Unofficial API for Python3.

Note: This library is UNSTABLE. I suggest use this api with shared note for limit view.

Example

Normal Workflowy and WeakWorkflowy(requires new class) are different.

from wfapi import *

# normal mode
wf = Workflowy(...)
node = wf.create(wf.root)
wf.edit(node, "Something")

# weak mode
class WeakWorkflowy(WFMixinWeak, Workflowy):
    pass

wf = WeakWorkflowy(...)
node = wf.root.create()
node.edit("Something")

Login Example

from wfapi import *

# login by password
Workflowy(username="username", password="password")

# or session id (no second argument)
Workflowy(sessionid="sessionid")

# or just use shared note is good idea
# if https://workflowy.com/s/abcABC1234 is access url
Workflowy("abcABC1234")

# if want to logged state and use shared note
Workflowy("abcABC1234", username="username", password="password")

Deamon (+ Weak) Example

from wfapi import *

class DeamonWeakWorkflowy(WFMixinDeamon, WFMixinWeak, Workflowy):
    pass

wf = DeamonWorkflowy(...)
wf.start()
node = wf.create(wf.root)
node.edit("Something")
wf.stop()

Node operations

from wfapi import *
class WeakWorkflowy(Workflowy):
    pass

wf = WeakWorkflowy(...)

# create nodes
node = wf.root.create()
node2 = wf.root.create()
assert not node
assert node2 not in node

# node relation
subnode = node.create()
subnode2 = node.create()
subnode3 = node.create()
assert node
assert len(node) == 3
assert subnode2 == node
assert subnode3.parent == node

# node support iter
for some in node:
  if subnode == some:
    break
else:
  assert False

subnode.edit("Welcome")
subnode.delete()
assert len(node) == 1

# edit node and marked as complete
subnode2.edit("test")
subnode2.edit(description="Welcome")
subnode2.complete()

# edit node
subnode3.edit("test2")
subnode3.uncomplete()

assert self[subnode3.projectid] is subnode3

for node in self:
  node.projectid # UUID-like str or "None"(DEFAULT_ROOT_NODE_ID)
  node.last_modified # last modified time.
  node.name # name
  node.children # children (or just iter node)
  node.description # description
  node.completed_at # complete marking time (or None)
  node.completed # [READ-ONLY] boolean value for completed.
  node.shared # [UNSTABLE] shared infomation
  node.parent # parent node (or None, that is root node)

# just print tree;
wf.root.pretty_print()
# or node.pretty_print()

Transaction example (only commit is supported)

from wfapi import *
class WeakWorkflowy(WFMixinWeak, Workflowy):
    pass

wf = WeakWorkflowy(...)

# transaction make execute command fast, support rollback yet.
with wf.transaction():
  for i in range(10):
    subnode3.create()

# threadsafe nested transactions is also suppported.
with wf.transaction():
  with wf.transaction():
    # just delete node
    subnode3.delete()

wfapi's People

Contributors

ecmaxp avatar fiatjaf avatar haaavk avatar

Stargazers

Michael Terry avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.