You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by se...@apache.org on 2017/12/13 14:03:41 UTC
[whimsy] branch master updated: Add get_pony_lists method to just
get the list names
This is an automated email from the ASF dual-hosted git repository.
sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git
The following commit(s) were added to refs/heads/master by this push:
new c7b082e Add get_pony_lists method to just get the list names
c7b082e is described below
commit c7b082e77ae463905f97ef882d6839fb32cd0cc7
Author: Sebb <se...@apache.org>
AuthorDate: Wed Dec 13 14:03:35 2017 +0000
Add get_pony_lists method to just get the list names
---
tools/ponyapi.rb | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/tools/ponyapi.rb b/tools/ponyapi.rb
index e97c200..8e1a6c6 100644
--- a/tools/ponyapi.rb
+++ b/tools/ponyapi.rb
@@ -21,6 +21,32 @@ module PonyAPI
# Must supply cookie = 'ponymail-logged-in-cookie' to show private lists
# if cookie == 'prompt' and the script is run interactively then
# you will be prompted to enter the cookie value
+ # The method writes the file 'lists.json' if dir != nil
+ # it returns the data as a hash
+ def get_pony_lists(dir, cookie=nil, sort_list=false)
+ jzon = get_pony_prefs(nil, cookie)
+ lists = jzon['lists']
+ if lists
+ if dir
+ # no real point sorting unless writing the file
+ lists = Hash[lists.sort] if sort_list
+ File.open(File.join("#{dir}", 'lists.json'), "w") do |f|
+ begin
+ f.puts JSON.pretty_generate(jzon)
+ rescue JSON::GeneratorError
+ puts "WARN:get_pony_lists() threw JSON::GeneratorError, continuing without pretty"
+ f.puts jzon
+ end
+ end
+ end
+ end
+ lists
+ end
+
+ # Get preferences including a summary of all mailing lists by domain
+ # Must supply cookie = 'ponymail-logged-in-cookie' to show private lists
+ # if cookie == 'prompt' and the script is run interactively then
+ # you will be prompted to enter the cookie value
# The method writes the file 'preferences.json' if dir != nil
# it returns the data as a hash
def get_pony_prefs(dir, cookie=nil, sort_list=false)
@@ -169,4 +195,5 @@ if __FILE__ == $0
# PonyAPI.get_pony_mbox('.', 'dev', 'whimsical', 2017, 01, nil)
# PonyAPI.get_pony_stats('.', 'dev', 'whimsical', 2017, 01, nil)
# puts PonyAPI.get_pony_prefs(nil, nil, true)['login'].inspect
+# puts PonyAPI.get_pony_lists(nil,nil,true).keys.length
end
--
To stop receiving notification emails like this one, please contact
['"commits@whimsical.apache.org" <co...@whimsical.apache.org>'].