Różnice między wybraną wersją a wersją aktualną.
Poprzednia rewizja po obu stronach Poprzednia wersja Nowa wersja | Poprzednia wersja | ||
it:scribd_up [2013/11/11 02:17] naczelnik [Użycie] |
it:scribd_up [2014/07/10 18:54] (aktualna) naczelnik [Kod] |
||
---|---|---|---|
Linia 13: | Linia 13: | ||
</ | </ | ||
====== Konfiguracja ====== | ====== Konfiguracja ====== | ||
- | W pliku "$PWD/ | + | Pozyskujemy klucz API z http:// |
+ | * $PWD/ | ||
+ | * $HOME/ | ||
+ | * wskazana przez parametr " | ||
+ | bazując | ||
< | < | ||
[api] | [api] | ||
Linia 29: | Linia 33: | ||
import ConfigParser | import ConfigParser | ||
from os.path import expanduser | from os.path import expanduser | ||
+ | import argparse | ||
+ | |||
+ | parser = argparse.ArgumentParser() | ||
+ | parser.add_argument(" | ||
+ | help=" | ||
+ | parser.add_argument(" | ||
+ | help=" | ||
+ | parser.add_argument(" | ||
+ | help=" | ||
+ | parser.add_argument(' | ||
+ | help=" | ||
+ | args =parser.parse_args() | ||
config = ConfigParser.ConfigParser() | config = ConfigParser.ConfigParser() | ||
- | config.read([' | + | config.read(args.config) |
scribd.config(config.get(' | scribd.config(config.get(' | ||
Linia 37: | Linia 53: | ||
def upload(filename): | def upload(filename): | ||
- | document = user.upload(open(filename, ' | + | |
+ | | ||
document.save() | document.save() | ||
- | return document.get_scribd_url() | + | return document |
def progress(bytes_sent, | def progress(bytes_sent, | ||
print >> stderr, "\r%s of %s (%s%%)" | print >> stderr, "\r%s of %s (%s%%)" | ||
- | if len(argv)<2: | + | for filename in args.filename: |
- | | + | doc = upload(filename) |
- | else: | + | |
- | if len(argv)> | + | att = doc.get_attributes() |
- | | + | text = "[scribd id=%s key=%s mode=scroll]" |
- | url = upload(filename) | + | else: |
- | print " | + | |
- | else: #==2 | + | print " |
- | print " | + | |
</ | </ | ||
~~DISCUSSION~~ | ~~DISCUSSION~~ |