6c886dce42ebprojects/vlaah-python/index.ko.txt132:6c886dce42eb |
224:1d46270eb038 → |
-rw-r--r--/projects/{pyfunge,transdate,versert,vlaah-python} added.
1 ## vim: syn=mako 2 3 **vlaah-python** 라이브러리는 [VLAAH](http://vlaah.com/)의 웹 API를 파이썬으로 감싼 것입니다. 4 5 6 사용법 7 ====== 8 9 먼저 [VLAAH API](http://api.vlaah.com/) 페이지에서 새 애플리케이션 키를 받으시길 바랍니다. 이 애플리케이션 키는 16진수 64자리로 예를 들면 다음과 같습니다.[^1] 10 11 3e102b5df7b5731f68a61a34c3d58185fe7e1585ef3bf5e99c0e42d92c34cf44 12 13 [^1]: 이 키는 예시를 들기 위해 아무렇게나 만든 것입니다. 좀 더 정확하게는, <`this is an example of VLAAH application key.`>의 SHA-256 해시입니다. 14 15 해당 애플리케이션 키를 사용해서 세션 객체를 생성합니다. 세션 객체에 User-Agent 문자열을 넣을 수도 있습니다. 16 17 >>> from vlaah import Session 18 >>> sess = Session('3e102b5df7b5731f68a61a34c3d58185fe7e1585' 19 'ef3bf5e99c0e42d92c34cf44', 'mearieflo/20081116') 20 >>> sess 21 <VLAAH Session: agent='mearieflo/20081114' 22 appkey='3e102b5df7b5731f68a61a34c3d58185fe7e1585ef3bf5e99c0e42d92c34cf44' 23 base='http://vlaah.com/'> 24 25 세션 객체의 find 메소드로 각 토픽에 해당하는 객체를 얻을 수 있습니다. 26 27 >>> sess.find(u'~dahlia') 28 <VLAAH Person: name='~dahlia' nick=u'\ud64d\ubbfc\ud76c'> 29 >>> sess.find(u'?35337') 30 <VLAAH Comment: name='?35337' topic=u'\uc720\ud589\uc5b4' 31 type='comment-minus' author='~shinvee'> 32 >>> sess.find(u'달이 차오른다 가자') 33 <VLAAH Topic: name=u'\ub2ec\uc774 \ucc28\uc624\ub978\ub2e4 \uac00\uc790'> 34 35 각 객체 별로 여러 속성과 메소드가 있습니다. 예를 들어 사람(`Person`) 객체에는 개인 이미지 주소를 가리키는 `picture_url` 속성이 있습니다. 36 37 >>> import urllib 38 >>> urllib.urlretrieve(sess.find(u'~crocodile').picture_url) 39 ('/var/folders/X7/X7Zjqfg5FquAv0k9T-M42U+++TI/-Tmp-/tmp5Z9qAv.png', 40 <httplib.HTTPMessage instance at 0xc6d4b8>) 41 42 VLAAH의 모든 주제에는 댓글이 붙을 수 있습니다. 댓글의 목록은 `comments` 메소드로 얻어 올 수 있습니다. 이 메소드의 결과는 리스트처럼 보이지만 실제로는 필요한 만큼 조금 조금씩 읽어 옵니다. 43 44 >>> sess.find(u'~dahlia').comments() 45 [<VLAAH Comment: name='?47454' topic='~dahlia' type='comment-minus' 46 author='~crocodile'>, <VLAAH Comment: name='?46843' topic='~dahlia' 47 type='comment-minus' author='~6601'>, ... (103 more)] 48 49 마찬가지로 객체의 속성으로 딸려 있는 여러 객체(이를테면 `Comment`의 `author` 속성)들은 필요할 때만 새로 읽어 들입니다. 이런 객체들은 `LazyPerson`과 같은 클래스로 처리되지만 사용자가 보기에는 투명하게 처리됩니다. 50 51 >>> sess.find(u'?45678').author 52 <VLAAH Person: name='~heungsub' nick=u'\uc774\ud765\uc12d'> 53 >>> type(_) 54 <class 'vlaah.person.LazyPerson'> 55 56 이런 특징만 빼면 라이브러리 API는 매우 직관적이기 때문에 원하는 코드를 빠르게 작성할 수 있습니다. 예를 들어 다음 코드는 특정 사용자 페이지에 "안녕하세요"라고 댓글을 단 모든 여자들(^^;)의 생일을 보여 줍니다. 57 58 >>> [cmt.author.birthday for cmt in sess.find(u'~dahlia').comments() 59 ... if cmt.author.gender == 'female' and 60 ... (cmt.body and u'안녕하세요' in cmt.body.as_text())] 61 [datetime.date(1990, 11, 5), datetime.date(1990, 2, 11), 62 datetime.date(1989, 6, 1), datetime.date(1990, 3, 12)] 63 64 65 사용하는 프로젝트 66 ================= 67 68 * [VV: VLAAH Versus](http://vlaahversus.appspot.com/) 69 70 vlaah-python 라이브러리를 사용해서 뭔가 그럴듯한 걸 만드셨다면 [연락](/about/contact)해 주세요. 이곳에 싣도록 하겠습니다. 71 72 73 내려 받기 74 ========= 75 76 vlaah-python 라이브러리의 최신 버전은 *0.9.0*으로 [여기](http://hg.mearie.org/vlaah-python/archive/vlaah-python-0.9.0.tar.gz)에서 받을 수 있습니다. 77 78 개발 버전은 [메아리 머큐리얼 저장소](http://hg.mearie.org/)에서 받을 수 있으며, 다음 명령을 사용하면 됩니다. 79 80 $ hg clone http://hg.mearie.org/vlaah-python/ 81 82 vlaah-python은 MIT 라이선스 하에 배포되며 저작권 명시만 하면 마음대로 쓸 수 있습니다. 83