Package etl :: Package component :: Package input :: Module facebook_in
[hide private]
[frames] | no frames]

Source Code for Module etl.component.input.facebook_in

 1  # -*- encoding: utf-8 -*- 
 2  ############################################################################## 
 3  # 
 4  #    ETL system- Extract Transfer Load system 
 5  #    Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved 
 6  #    $Id$ 
 7  # 
 8  #    This program is free software: you can redistribute it and/or modify 
 9  #    it under the terms of the GNU General Public License as published by 
10  #    the Free Software Foundation, either version 3 of the License, or 
11  #    (at your option) any later version. 
12  # 
13  #    This program is distributed in the hope that it will be useful, 
14  #    but WITHOUT ANY WARRANTY; without even the implied warranty of 
15  #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
16  #    GNU General Public License for more details. 
17  # 
18  #    You should have received a copy of the GNU General Public License 
19  #    along with this program.  If not, see <http://www.gnu.org/licenses/>. 
20  # 
21  ############################################################################## 
22  """ 
23  This is an ETL Component that is used to read data from facebook. 
24   
25   Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). 
26   GNU General Public License. 
27  """ 
28   
29  from etl.component import component 
30   
31 -class facebook_in(component):
32 """ 33 This is an ETL Component that is used to read data from facebook. 34 35 Type : Data Component. 36 Computing Performance : Streamline. 37 Input Flows : 0. 38 * .* : Nothing. 39 Output Flows : 0-x. 40 * .* : Returns the main flow with data. 41 """ 42
43 - def __init__(self, facebook_connector, method, domain=[], fields=['name'], name='component.input.facebook_in', transformer=None, row_limit=0):
44 """ 45 Required Parameters 46 facebook_connector : Facebook connector. 47 method : Name of the method which is going to be called to connector to fetch data from facebook. 48 domain : Domain List to put domain. 49 fields : Fields List. 50 51 Extra Parameters 52 name : Name of Component. 53 transformer : Transformer object to transform string data into particular object. 54 row_limit : Limited records are sent to destination if row limit is specified. If row limit is 0, all records are sent. 55 """ 56 super(facebook_in, self).__init__(name=name, connector=facebook_connector, transformer=transformer, row_limit=row_limit) 57 self._type = 'component.input.facebook_in' 58 self.method = method 59 self.domain = domain 60 self.fields = fields
61
62 - def __copy__(self):
63 res = facebook_in(self.connector, self.method, self.domain, self.fields, self.name, self.transformer, self.row_limit) 64 return res
65
66 - def process(self):
67 facebook = self.connector.open() 68 rows = self.connector.execute(facebook, self.method, fields=self.fields) 69 for row in rows: 70 if row: 71 yield row, 'main' 72 73 # fields = ['uid', 'name', 'birthday', 'about_me', 'activities', 'affiliations', 'books', 'current_location', 'education_history', 'email_hashes', 'first_name','has_added_app', 'hometown_location', 'hs_info', 'hs_info', 'hs_info', 'hs_info', 'hs_info', 'meeting_for', 'meeting_sex', 'movies', 'music','notes_count', 'pic', 'pic_with_logo', 'pic_big', 'pic_big_with_logo', 'pic_small', 'pic_small_with_logo', 'pic_square', 'pic_square_with_logo','political', 'profile_update_time', 'profile_url', 'proxied_email', 'quotes', 'relationship_status', 'religion', 'sex', 'significant_other_id'] 74
75 -def test():
76 from etl_test import etl_test 77 import etl 78 facebook_conn = etl.connector.facebook_connector('http://facebook.com', 'modiinfo@gmail.com') 79 test1 = etl_test.etl_component_test(facebook_in(facebook_conn, 'get_user_events')) 80 res = test1.output()
81 82 if __name__ == '__main__': 83 pass 84 #test() 85