[09:36:46] hi [09:37:02] hi [09:37:27] yesterday I gave some thought on the possible OOP design for making it smooth to add new glams to our tool [09:37:52] I will tell you about them [09:38:08] Please correct me when I am wrong [09:38:15] k [09:38:42] So when a new glam needs to be added we will need to make the following files [09:39:04] 1. A new form for taking input from the end user [09:39:40] 2. Add an entry into the list from where the glam dropdown will be populated [09:40:03] 3. Make a new class that will override a method of the base class [09:40:43] Now about the base class: [09:41:09] why can't #2 be dynamically generated? [09:42:10] meaning? [09:43:28] I mean, why do you need an extra list of glams when you have all the glam classes loaded [09:45:04] ok but I don't know how the dropdown can be populated dynamically. Do we have a function in the class to do that? [09:47:52] youtube-dl's method: https://github.com/rg3/youtube-dl/blob/master/youtube_dl/extractor/__init__.py [09:51:08] ok [09:52:58] what is returned by globals().items()? [09:52:59] https://github.com/rg3/youtube-dl/blob/master/youtube_dl/extractor/__init__.py#L13 [09:56:46] https://docs.python.org/2/library/functions.html#globals [09:57:11] https://docs.python.org/2/library/stdtypes.html#dict.items [09:57:32] ok [10:01:06] so this will basically return all the identifiers in the global symbol table in dictionary form. [10:01:16] Is that correct? [10:02:17] And from there we will have to get the glam names to put into the dropdown. [10:02:21] that's globals() [10:02:51] yeah key, value pairs [10:02:56] then there's .items() that will be an iterable that yields (key, val) tuples [10:03:18] right [10:03:20] And from there we will have to get the glam names to put into the dropdown. <= yeah, that's one way [10:04:14] is there a better way? [10:04:44] it's hard to say better or worse [10:04:56] another way would be to use metaclasses [10:05:14] yet another way would be to use a registry [10:06:14] nice [10:08:13] Now about the base class: [10:08:32] It has two methods [10:08:54] i. method that gets a blank template [10:09:21] ii. method that fills the template based on values received from the parsed json [10:09:30] parsed json? [10:10:05] yeah the jsob from the url given by end user [10:10:09] *json [10:10:13] hmm [10:10:23] I'll comment after you finish [10:10:37] finish coding? [10:10:58] finish "Now about the base class:" [10:11:02] ok [10:13:08] method that gets a blank template: there are several possible templates - Artwork, Art_Photo, Photograph. So here a decision has to be made which template is appropriate in the given context [10:14:56] ii. method that fills the template: sorry url is be glam specific. so this method has to be overridden by the glam specific derived class [10:16:27] so I think both methods be overridden since both require glam specific details [10:18:00] Question: How to decide which blank template to use in method i? [10:19:58] the glam class shall provide it [10:20:17] the base class shall provide a fallback if the glam classes do not [10:21:28] alternatively the "filling template" could be done in the base class, with values provided by glam classes [10:24:02] Since one glam can have images that are of separate categories qualifying to get different templates which template to choose is question that has to be answered nased on on some info from the parsed json. [10:24:20] sure [10:24:30] @property [10:24:55] I had so many typos sorry about them [10:25:39] it's okay. let's focus on the project itself and not the typos [10:26:05] @property means there will be some field in the json? [10:26:31] https://docs.python.org/2/library/functions.html#property [10:27:33] I would probably make each file an instance of the glam class [10:28:41] ok [10:28:54] what do you mean by 'each file'? [10:29:06] oh, sorry [10:29:13] I meant an upload task [10:30:36] why so? [10:30:50] what would you do? [10:31:51] I am not sure what's best to do. As of now, once the template is built simply call pywikibot and get the upload done. [10:32:54] I still prefer if the uploader gets to edit the description page before the actual upload [10:33:06] have you tried v2c? [10:33:12] yes [10:34:02] but even if the upload fails the edit description takes place [10:34:07] there is possibility that the extracted description may not be very suitable [10:34:12] ? [10:34:36] no, the description is passed to the upload function [10:34:45] once the upload starts, there's no editing [10:35:34] there is possibility that the extracted description may not be very suitable <= how to deal with this? [10:35:45] let the user edit before upload [10:36:04] oh nice [10:36:23] have you actually tried to create a task with v2c? [10:36:26] that's very much necessary step I think [10:36:55] yes I did but even though I cancelled since it was taking time My Upload page got edited :( [10:38:00] Also probably it edited the new uploads page from where someone gave me a no license notice [10:39:08] https://usercontent.irccloud-cdn.com/file/X5MBeiAE/Screenshot%20from%202017-07-02%2018-38-48.png [10:39:18] v2c's edit description step [10:40:29] yeah it gives the option to change all the fields in the template. right? [10:40:41] yes, plain wikitext [10:41:52] I think it edits the My Uploads page of the user even before the upload is complete [10:42:11] Is that right? [10:42:17] you mean https://commons.wikimedia.org/w/index.php?title=Special:ListFiles/Zhuyifei1999&ilshowall=1 ? [10:42:18] no [10:42:57] the list is consistent with the uploads the user have done and is still visible (not deleted) [10:43:58] yeah sorry [10:44:05] you are right [10:44:51] It probably adds the video as an entry to that page where recently uploaded videos are there [10:44:51] even before the upload is finished [10:46:15] ? [10:46:39] you mean added to v2c's list? [10:47:49] wait [10:48:06] you had sent me a link [10:48:11] ? [10:48:31] a page where the recently uploaded videos go [10:48:51] https://commons.wikimedia.org/w/index.php?title=Special:RecentChanges&tagfilter=OAuth+CID:+394 ? [10:48:59] v2c's RC ^ [10:49:46] no wait [10:49:49] I will find it [10:50:59] https://commons.wikimedia.org/wiki/Special:RecentChanges [10:51:26] yeah that's all changes [10:51:35] yes [10:51:49] once the upload finish an entry will be added to that page [10:52:29] Ok after completion [10:52:35] yeah [10:52:41] unless mediawiki breaks [10:53:05] which happens once in a while, if you aren't aware :P [10:53:32] oh is it? [10:53:44] good to know :) [10:54:02] well, breaks in various ways, just search phab [10:54:11] ok [10:54:35] https://phabricator.wikimedia.org/maniphest/?project=PHID-PROJ-iodggnykzbdrhsjfkg4q&statuses=open()&group=none&order=newest#R [10:55:20] ok [10:56:01] Well I still don't have enough clarity on the issue of how a template will be chosen for a given image [10:57:06] Is it not necessary that the corresponding json will give some info? [11:00:05] glam may or may not provide the information [11:00:26] :( [11:00:52] @property will help? [11:01:47] no, it's just to make a property [11:04:00] then how to do it? [11:04:01] I mean the property can be dynamic [11:04:41] the getter behind the property can do all the processing [11:05:27] ok [11:05:35] use the glam-provided information if available. otherwise, have a fallback [11:05:59] I will read more on this @property and its usage [11:06:30] k [11:07:06] it's basically how you can customize an_instance.a_property [11:07:43] and make the property call getter/setter/del-er, when the property is get / set / del [11:08:05] that's one way though [11:08:54] ok [11:09:09] another is to make the glam classes call a function in the base class, and a parameter indicating which template to use [11:09:31] but I don't think that looks as elegant as @property [11:10:31] oh I see [11:18:14] need a break now [11:18:19] k