function
stringlengths
11
56k
repo_name
stringlengths
5
60
features
list
def test_the_user_update_reminder(self): reminders = self.the_user1.get_web_reminders() self.assertTrue(isinstance(reminders, dict)) self.assertEqual(reminders['vk'], True) self.assertEqual(reminders['app_download'], True) self.the_user1.update_reminder('vk', False) sel...
OlegKlimenko/Plamber
[ 9, 1, 9, 28, 1487368387 ]
def test_removing_user_objects(self): """ Must remove django User instance after 'app.models.TheUser' objects was deleted. """ the_user3 = TheUser.objects.get(id_user__username='user3') the_user4 = TheUser.objects.get(id_user__email='user4@user4.com') the_user3.delete() ...
OlegKlimenko/Plamber
[ 9, 1, 9, 28, 1487368387 ]
def test_created_categories(self): self.assertEqual(Category.objects.all().count(), 2) self.assertNotEqual(self.category1, self.category2)
OlegKlimenko/Plamber
[ 9, 1, 9, 28, 1487368387 ]
def test_categories_str(self): self.assertEqual(str(self.category1), 'category1') self.assertEqual(str(self.category2), 'category2')
OlegKlimenko/Plamber
[ 9, 1, 9, 28, 1487368387 ]
def test_created_authors(self): self.assertEqual(Author.objects.all().count(), 5) self.assertNotEqual(self.author1, self.author2)
OlegKlimenko/Plamber
[ 9, 1, 9, 28, 1487368387 ]
def test_get_authors_list(self): """ Must return authors list depending on different letters/letter case/words/symbols. """ self.assertEqual(Author.get_authors_list('bEst'), ['Best Author 1']) self.assertEqual(Author.get_authors_list('1'), ['Best Author 1']) self.assertEq...
OlegKlimenko/Plamber
[ 9, 1, 9, 28, 1487368387 ]
def test_get_authors_list_with_escaping(self): self.assertEqual(Author.get_authors_list("'", True), ['O'Connor']) self.assertEqual(Author.get_authors_list("Connor", True), ['O'Connor']) self.assertEqual( Author.get_authors_list('b', True), ['Best Author 1', '<A...
OlegKlimenko/Plamber
[ 9, 1, 9, 28, 1487368387 ]
def test_get_authors_list_without_escaping(self): self.assertEqual(Author.get_authors_list("'"), ["O'Connor"]) self.assertEqual(Author.get_authors_list("Connor", False), ["O'Connor"]) self.assertEqual(Author.get_authors_list('b'), ['Best Author 1', '<AuthorSpecialSymbols>&"']) self.asser...
OlegKlimenko/Plamber
[ 9, 1, 9, 28, 1487368387 ]
def test_created_language(self): self.assertEqual(Language.objects.all().count(), 2) self.assertNotEqual(self.author1, self.author2)
OlegKlimenko/Plamber
[ 9, 1, 9, 28, 1487368387 ]
def test_created_books(self): books = Book.objects.all() self.assertEqual(books.count(), 7) self.assertEqual(books.filter(private_book=True).count(), 2) self.assertEqual(books.filter(id_category=self.category1).count(), 4) self.assertEqual(books.filter(id_author=self.author1).co...
OlegKlimenko/Plamber
[ 9, 1, 9, 28, 1487368387 ]
def test_get_related_objects_for_create(self): test_book_path = os.path.join(TEST_DATA_DIR, 'test_book.pdf') form_data = { 'bookname': 'The new book', 'author': 'trueAuthorNew', 'category': 'category1', 'language': 'English', 'about': 'about b...
OlegKlimenko/Plamber
[ 9, 1, 9, 28, 1487368387 ]
def test_get_related_objects_create_api(self): """ Must generate Book related data when creates a Book object for API calls. New author must be returned if it's name not present in the Author model. """ test_data = {'author': 'trueAuthorNew', 'category': 'category2', 'language': ...
OlegKlimenko/Plamber
[ 9, 1, 9, 28, 1487368387 ]
def test_get_related_objects_selected_book_unknown_user(self): """ Must generate selected book related data for unknown (anonymous) users. """ third_book = Book.objects.get(book_name='Third Book') sixth_book = Book.objects.get(book_name='Sixth Book') self.assertTrue(isin...
OlegKlimenko/Plamber
[ 9, 1, 9, 28, 1487368387 ]
def test_get_related_objects_selected_book_added_user(self): """ This case is testing only 'added_book' param, because for user who is reading the book only this attribute will change relatively to function above. """ third_book = Book.objects.get(book_name='Third Book') ...
OlegKlimenko/Plamber
[ 9, 1, 9, 28, 1487368387 ]
def test_get_related_objects_selected_book_with_user_key(self): """ Tests returning data for related objects for selected book with 'user_key' attribute, meaning that user is anonymous (i.e. not logged) but with using user key. Done for API requests access. """ third_book = Book....
OlegKlimenko/Plamber
[ 9, 1, 9, 28, 1487368387 ]
def test_sort_by_book_name_category1(self): """ Must generate correct dictionaries for anonymous users, users with private books and without. Testing first category. """ first_book = Book.objects.get(book_name='First Book') third_book = Book.objects.get(book_name='Third B...
OlegKlimenko/Plamber
[ 9, 1, 9, 28, 1487368387 ]
def test_sort_by_book_name_category2(self): """ Must generate correct dictionaries for anonymous users, users with private books and without. Testing first category. """ fifth_book = Book.objects.get(book_name='Fifth Book') seventh_book = Book.objects.get(book_name='Seven...
OlegKlimenko/Plamber
[ 9, 1, 9, 28, 1487368387 ]
def test_sort_by_author_category1(self): """ Must generate correct dictionaries for anonymous users, users with private books and without. Testing returned book authors at first category. """ self.assertTrue(isinstance(Book.sort_by_author(self.anonymous_user, self.category1), lis...
OlegKlimenko/Plamber
[ 9, 1, 9, 28, 1487368387 ]
def test_sort_by_author_category2(self): """ Must generate correct dictionaries for anonymous users, users with private books and without. Testing returned book authors at second category. """ escaped_author_name = '&lt;AuthorSpecialSymbols&gt;&amp;&quot;' self.assertEqu...
OlegKlimenko/Plamber
[ 9, 1, 9, 28, 1487368387 ]
def test_sort_by_estimation_category1(self): """ Must generate correct dictionaries for anonymous users, users with private books and without. Testing returned book rating at first category. """ self.assertTrue(isinstance(Book.sort_by_estimation(self.anonymous_user, self.category...
OlegKlimenko/Plamber
[ 9, 1, 9, 28, 1487368387 ]
def test_sort_by_estimation_category2(self): """ Must generate correct dictionaries for anonymous users, users with private books and without. Testing returned book rating at second category. """ self.assertEqual(len(Book.sort_by_estimation(self.anonymous_user, self.category2)), ...
OlegKlimenko/Plamber
[ 9, 1, 9, 28, 1487368387 ]
def test_sort_by_readable(self): """ Must generate correct data by most readable books for anonymous users and users with private books. Testing count of sorted books with and without selected categories. """ sorted_structure = Book.sort_by_readable(self.anonymous_user, self.cate...
OlegKlimenko/Plamber
[ 9, 1, 9, 28, 1487368387 ]
def test_generate_books(self): """ Must generate correct dictionaries for Book data. """ books = Book.objects.all() self.assertTrue(isinstance(Book.generate_books(books), list)) self.assertEqual(len(Book.generate_books(books)), 7) self.assertEqual(len(Book.genera...
OlegKlimenko/Plamber
[ 9, 1, 9, 28, 1487368387 ]
def test_fetch_books(self): """ Must generate list of dicts with Books data depending on different criteria. """ self.assertTrue(isinstance(Book.fetch_books('book'), list)) self.assertEqual(len(Book.fetch_books('Second Book')), 1) self.assertEqual(len(Book.fetch_books('b...
OlegKlimenko/Plamber
[ 9, 1, 9, 28, 1487368387 ]
def test_generate_existing_books(self): """ Must generate list of dicts with Books data depending on different criteria and excluding private books. """ self.assertTrue(isinstance(Book.generate_existing_books('book'), list)) self.assertEqual(len(Book.generate_existing_books('book...
OlegKlimenko/Plamber
[ 9, 1, 9, 28, 1487368387 ]
def test_exclude_private_books(self): """ Must generate query sets or lists with Books depending on user type. """ all_books = Book.objects.all() list_all_books = list(all_books) self.assertEqual(Book.exclude_private_books(self.the_user1.id_user, all_books).count(), 7) ...
OlegKlimenko/Plamber
[ 9, 1, 9, 28, 1487368387 ]
def test_added_books(self): self.assertEqual(AddedBook.objects.all().count(), 8) self.assertEqual(AddedBook.objects.filter(id_user=self.the_user1).count(), 3) self.assertEqual(AddedBook.objects.filter(id_user=self.the_user2).count(), 3) self.assertEqual(AddedBook.objects.filter(id_user=...
OlegKlimenko/Plamber
[ 9, 1, 9, 28, 1487368387 ]
def test_added_books_change(self): """ Must save book page after changing it. """ added_book3 = AddedBook.objects.get(id_user=self.the_user1, id_book=Book.objects.get(book_name='Third Book')) added_book6 = AddedBook.objects.get(id_user=self.the_user2, id_book=Book.objects.get(boo...
OlegKlimenko/Plamber
[ 9, 1, 9, 28, 1487368387 ]
def test_added_books_delete(self): added_book_third = AddedBook.objects.get(id_user=self.the_user1, id_book=Book.objects.get(book_name='Third Book')) added_book_sixth = AddedBook.objects.get(id_user=self.the_user2, ...
OlegKlimenko/Plamber
[ 9, 1, 9, 28, 1487368387 ]
def test_get_user_added_book(self): """ Must generate list of books that added by user (reading by user). """ self.assertTrue(self.anonymous_user.is_anonymous) self.assertEqual(len(AddedBook.get_user_added_books(self.anonymous_user)), 0) self.assertEqual(AddedBook.get_use...
OlegKlimenko/Plamber
[ 9, 1, 9, 28, 1487368387 ]
def test_get_count_added(self): """ Must return count how many users is reading some book. """ third_book = Book.objects.get(book_name='Third Book') sixth_book = Book.objects.get(book_name='Sixth Book') not_existing_id = 10000 self.assertEqual(AddedBook.get_count...
OlegKlimenko/Plamber
[ 9, 1, 9, 28, 1487368387 ]
def test_book_rating(self): self.assertEqual(BookRating.objects.all().count(), 6) self.assertEqual(BookRating.objects.filter(id_book=Book.objects.filter(book_name='Third Book')).count(), 3) self.assertEqual(BookRating.objects.filter(id_user=self.the_user1).count(), 3) self.assertEqual(Bo...
OlegKlimenko/Plamber
[ 9, 1, 9, 28, 1487368387 ]
def test_changed_book_rating(self): removed_rating = BookRating.objects.get(id_book=Book.objects.get(book_name='Third Book'), id_user=self.the_user1) removed_rating.delete() self.assertEqual(BookRating.objects.all().count(), 5) changed_rat...
OlegKlimenko/Plamber
[ 9, 1, 9, 28, 1487368387 ]
def test_book_comment(self): self.assertEqual(BookComment.objects.all().count(), 5) self.assertEqual(BookComment.objects.filter(id_user=self.the_user1).count(), 3) self.assertEqual(BookComment.objects.filter(id_book=Book.objects.get(book_name='Second Book')).count(), 2) self.assertEqual(...
OlegKlimenko/Plamber
[ 9, 1, 9, 28, 1487368387 ]
def test_post_messages(self): self.assertEqual(Post.objects.all().count(), 3) self.assertEqual(Post.objects.filter(user=self.the_user1).count(), 2) self.assertEqual(Post.objects.filter(user=self.the_user2).count(), 1) deleted_post = Post.objects.get(user=self.the_user1, heading='post 2'...
OlegKlimenko/Plamber
[ 9, 1, 9, 28, 1487368387 ]
def test_support_messages(self): self.assertEqual(SupportMessage.objects.all().count(), 4) self.assertEqual(SupportMessage.objects.filter(email='testemail1@mail.co').count(), 2) self.assertEqual(SupportMessage.objects.filter(email='test_email22@mail.co').count(), 1) self.assertEqual(Supp...
OlegKlimenko/Plamber
[ 9, 1, 9, 28, 1487368387 ]
def main(): module = AnsibleModule( argument_spec = dict( hostname = dict(required=True), username = dict(required=True), password = dict(required=True, no_log=True), settings = dict(required=False, type='dict'), parameter = dict( required = True, choices = ['n...
zahodi/ansible-mikrotik
[ 93, 34, 93, 17, 1484089137 ]
def connect(implicit_execution=False): config = dict(hf.config.items("database")) hf.database.engine = engine_from_config(config, prefix="") if implicit_execution: metadata.bind = hf.database.engine
HappyFaceMonitoring/HappyFace
[ 2, 6, 2, 1, 1405423472 ]
def __init__(self, nclass: int, model: Callable, **kwargs): super().__init__(nclass, kwargs) self.model: objax.Module = model(colors=3, nclass=nclass, **kwargs) self.model_ema = objax.optimizer.ExponentialMovingAverageModule(self.model, momentum=0.999) if FLAGS.arch.endswith('pretrain'):...
google-research/adamatch
[ 52, 5, 52, 5, 1626812263 ]
def __init__(self, **kwargs): self.live_trials = {} self.counter = {"result": 0, "complete": 0} self.final_results = [] self.stall = False self.results = [] super(_MockSearcher, self).__init__(**kwargs)
ray-project/ray
[ 24488, 4264, 24488, 2914, 1477424310 ]
def on_trial_result(self, trial_id: str, result: Dict): self.counter["result"] += 1 self.results += [result]
ray-project/ray
[ 24488, 4264, 24488, 2914, 1477424310 ]
def _process_result(self, result: Dict): self.final_results += [result]
ray-project/ray
[ 24488, 4264, 24488, 2914, 1477424310 ]
def __init__(self, max_concurrent: Optional[int] = None, **kwargs): self.searcher = _MockSearcher(**kwargs) if max_concurrent: self.searcher = ConcurrencyLimiter( self.searcher, max_concurrent=max_concurrent ) super(_MockSuggestionAlgorithm, self).__init__...
ray-project/ray
[ 24488, 4264, 24488, 2914, 1477424310 ]
def live_trials(self) -> List[Trial]: return self.searcher.live_trials
ray-project/ray
[ 24488, 4264, 24488, 2914, 1477424310 ]
def woof(self): print("Woof", self)
sparkslabs/guild
[ 24, 5, 24, 1, 1348350458 ]
def process(self): #print(" ", end="") pass
sparkslabs/guild
[ 24, 5, 24, 1, 1348350458 ]
def produce(self): pass
sparkslabs/guild
[ 24, 5, 24, 1, 1348350458 ]
def __init__(self): self.count = 0 super(Dog, self).__init__()
sparkslabs/guild
[ 24, 5, 24, 1, 1348350458 ]
def process(self): self.count += 1 print("I don't go meow", self.count) if self.count >= 20: self.stop() return False
sparkslabs/guild
[ 24, 5, 24, 1, 1348350458 ]
def test_properties(self): ocm = 'ocn460678076' vol = 'V.1' noid = '1234' volume = SolrVolume(label='%s_%s' % (ocm, vol), pid='testpid:%s' % noid) self.assertEqual(ocm, volume.control_key) self.assertEqual(vol, volume.volume) self.assertE...
emory-libraries/readux
[ 27, 13, 27, 13, 1400170870 ]
def test_voyant_url(self): # Volume with English Lang volume1 = SolrVolume(label='ocn460678076_V.1', pid='testpid:1234', language='eng') url = volume1.voyant_url() self.assert_(urlencode({'corpus': volume1.pid}) in url, 'voyant url should include...
emory-libraries/readux
[ 27, 13, 27, 13, 1400170870 ]
def test_annotations(self): # find annotations associated with a volume, optionally filtered # by user User = get_user_model() testuser = User.objects.create(username='tester') testadmin = User.objects.create(username='super', is_superuser=True) mockapi = Mock() ...
emory-libraries/readux
[ 27, 13, 27, 13, 1400170870 ]
def test_has_tei(self): mockapi = Mock() vol = Volume(mockapi, 'vol:1') p1 = Mock(spec=Page) p1.tei.exists = False p2 = Mock(spec=Page) p2.tei.exists = False vol.pages = [p1, p2] self.assertFalse(vol.has_tei) p2.tei.exists = True self.asser...
emory-libraries/readux
[ 27, 13, 27, 13, 1400170870 ]
def setUp(self): # use uningested objects for testing purposes repo = Repository() self.vol = repo.get_object(type=VolumeV1_0) self.vol.label = 'ocn460678076_V.1' self.vol.pid = 'rdxtest:4606'
emory-libraries/readux
[ 27, 13, 27, 13, 1400170870 ]
def test_rdf_dc(self): # add metadata to test rdf generated ark_uri = 'http://pid.co/ark:/12345/ba45' self.vol.dc.content.identifier_list.append(ark_uri) self.vol.dc.content.title = 'Sunset, a novel' self.vol.dc.content.format = 'application/pdf' self.vol.dc.content.langu...
emory-libraries/readux
[ 27, 13, 27, 13, 1400170870 ]
def test_voyant_url(self): # NOTE: this test is semi-redundant with the same test for the SolrVolume, # but since the method is implemented in BaseVolume and depends on # properties set on the subclasses, testing here to ensure it works # in both cases # no language self...
emory-libraries/readux
[ 27, 13, 27, 13, 1400170870 ]
def test_ocr_ids(self): # pach in fixture ocr content with patch.object(self.vol, 'ocr') as mockocr: mockocr.exists = True ocr_xml = load_xmlobject_from_file(os.path.join(FIXTURE_DIR, 'abbyyocr_fr8v2.xml')) mockocr.content = ocr_xml self.a...
emory-libraries/readux
[ 27, 13, 27, 13, 1400170870 ]
def setUp(self): self.mets_alto = load_xmlobject_from_file(self.metsalto_doc, XmlObject)
emory-libraries/readux
[ 27, 13, 27, 13, 1400170870 ]
def setUp(self): self.fr6v1 = load_xmlobject_from_file(self.fr6v1_doc, abbyyocr.Document) self.fr8v2 = load_xmlobject_from_file(self.fr8v2_doc, abbyyocr.Document)
emory-libraries/readux
[ 27, 13, 27, 13, 1400170870 ]
def test_page(self): # finereader 6 v1 self.assertEqual(1500, self.fr6v1.pages[0].width) self.assertEqual(2174, self.fr6v1.pages[0].height) self.assertEqual(300, self.fr6v1.pages[0].resolution) # second page has picture block, no text self.assertEqual(1, len(self.fr6v1.pa...
emory-libraries/readux
[ 27, 13, 27, 13, 1400170870 ]
def test_paragraph_line(self): # finereader 6 v1 para = self.fr6v1.pages[3].paragraphs[0] # untested: align, left/right/start indent self.assert_(para.lines) self.assert_(isinstance(para.lines[0], abbyyocr.Line)) line = para.lines[0] self.assertEqual(283, line.bas...
emory-libraries/readux
[ 27, 13, 27, 13, 1400170870 ]
def setup_method(self, method): pass
intel-analytics/analytics-zoo
[ 2553, 722, 2553, 534, 1493951250 ]
def create_data(self): cycles = 10 time = np.arange(0, cycles * np.pi, 0.01) data = np.sin(time) data[600:800] = 10 return data
intel-analytics/analytics-zoo
[ 2553, 722, 2553, 534, 1493951250 ]
def test_ae_fit_score_rolled_pytorch(self): y = self.create_data() ad = AEDetector(roll_len=314, backend="torch") ad.fit(y) anomaly_scores = ad.score() assert len(anomaly_scores) == len(y) anomaly_indexes = ad.anomaly_indexes() assert len(anomaly_indexes) == int(a...
intel-analytics/analytics-zoo
[ 2553, 722, 2553, 534, 1493951250 ]
def random_age(path=''): graph = Graph('IOMemory', BNode()) graph.add((URIRef(path), FOAF.age, Literal(random.randint(20, 50)))) return graph
hufman/flask_rdf
[ 14, 3, 14, 1, 1402031150 ]
def main(): ast = test_common.Ami() ast.username = sys.argv[1] ast.password = sys.argv[2] if ast.conn() == False: print("Could not connect.") return 1
pchero/asterisk-outbound
[ 9, 5, 9, 3, 1446160917 ]
def _create_user(self, username, email=None, password=None, **extra_fields): now = timezone.now() email = self.normalize_email(email) user = self.model(username=username, email=email, last_login=now, ...
AllMyChanges/allmychanges.com
[ 3, 1, 3, 18, 1398338343 ]
def create_user(self, username, email=None, password=None, **extra_fields): if email and self.filter(email=email).count() > 0: raise ValueError('User with email "{0}" already exists'.format(email)) url = settings.BASE_URL + reverse('admin-user-profile', ...
AllMyChanges/allmychanges.com
[ 3, 1, 3, 18, 1398338343 ]
def get_avatar(self, size):
AllMyChanges/allmychanges.com
[ 3, 1, 3, 18, 1398338343 ]
def is_superuser(self): return self.username in settings.SUPERUSERS
AllMyChanges/allmychanges.com
[ 3, 1, 3, 18, 1398338343 ]
def track(self, changelog): if not self.does_track(changelog): if changelog.namespace == 'web' and changelog.name == 'allmychanges': action = 'track-allmychanges' action_description = 'User tracked our project\'s changelog.' else: action = ...
AllMyChanges/allmychanges.com
[ 3, 1, 3, 18, 1398338343 ]
def does_skip(self, changelog): """Check if this user skipped this changelog in package selector.""" return self.skips_changelogs.filter(pk=changelog.id).exists()
AllMyChanges/allmychanges.com
[ 3, 1, 3, 18, 1398338343 ]
def add_feed_item(self, version): if self.send_digest == 'never': return None return FeedItem.objects.create(user=self, version=version)
AllMyChanges/allmychanges.com
[ 3, 1, 3, 18, 1398338343 ]
def __unicode__(self): return self.email
AllMyChanges/allmychanges.com
[ 3, 1, 3, 18, 1398338343 ]
def download(self, downloader, report_back=lambda message, level=logging.INFO: None): """This method fetches repository into a temporary directory and returns path to this directory. It can report about downloading status using callback `report_back`. Everything what wi...
AllMyChanges/allmychanges.com
[ 3, 1, 3, 18, 1398338343 ]
def get_ignore_list(self): """Returns a list with all filenames and directories to ignore when searching a changelog.""" return split_filenames(self.ignore_list)
AllMyChanges/allmychanges.com
[ 3, 1, 3, 18, 1398338343 ]
def get_search_list(self): """Returns a list with all filenames and directories to check when searching a changelog.""" return parse_search_list(self.search_list)
AllMyChanges/allmychanges.com
[ 3, 1, 3, 18, 1398338343 ]
def process(item): if isinstance(item, tuple) and item[1]: return u':'.join(item) else: return item
AllMyChanges/allmychanges.com
[ 3, 1, 3, 18, 1398338343 ]
def only_active(self): # active changelog is good and not paused queryset = self.good() return queryset.filter(paused_at=None)
AllMyChanges/allmychanges.com
[ 3, 1, 3, 18, 1398338343 ]
def unsuccessful(self): return self.all().filter( Q(name=None) | Q(namespace=None) | Q(downloader=None) | Q(source=''))
AllMyChanges/allmychanges.com
[ 3, 1, 3, 18, 1398338343 ]
def __unicode__(self): return u'Changelog from {0}'.format(self.source)
AllMyChanges/allmychanges.com
[ 3, 1, 3, 18, 1398338343 ]
def latest_versions(self, limit): return self.versions.exclude(unreleased=True) \ .order_by('-order_idx')[:limit]
AllMyChanges/allmychanges.com
[ 3, 1, 3, 18, 1398338343 ]
def get_display_name(self): return u'{0}/{1}'.format( self.namespace, self.name)
AllMyChanges/allmychanges.com
[ 3, 1, 3, 18, 1398338343 ]
def create_uniq_name(namespace, name): """Returns a name which is unique in given namespace. Name is created by incrementing a value.""" if namespace and name: base_name = name counter = 0 while Changelog.objects.filter( namespace=namespac...
AllMyChanges/allmychanges.com
[ 3, 1, 3, 18, 1398338343 ]
def get_all_namespaces(like=None): queryset = Changelog.objects.all() if like is not None: queryset = queryset.filter( namespace__iexact=like ) return list(queryset.values_list('namespace', flat=True).distinct())
AllMyChanges/allmychanges.com
[ 3, 1, 3, 18, 1398338343 ]
def normalize_namespaces(): namespaces_usage = defaultdict(int) changelogs_with_namespaces = Changelog.objects.exclude(namespace=None) for namespace in changelogs_with_namespaces.values_list('namespace', flat=True): namespaces_usage[namespace] += 1 def normalize(namespace):...
AllMyChanges/allmychanges.com
[ 3, 1, 3, 18, 1398338343 ]
def get_absolute_url(self): return reverse('project', namespace=self.namespace, name=self.name)
AllMyChanges/allmychanges.com
[ 3, 1, 3, 18, 1398338343 ]
def is_unsuccessful(self): return self.name is None or \ self.namespace is None or \ self.downloader is None or \ not self.source
AllMyChanges/allmychanges.com
[ 3, 1, 3, 18, 1398338343 ]
def add_to_moderators(self, user, light_user=None): """Adds user to moderators and returns 'normal' or 'light' if it really added him. In case if user already was a moderator, returns None.""" if not self.is_moderator(user, light_user): if user.is_authenticated(): ...
AllMyChanges/allmychanges.com
[ 3, 1, 3, 18, 1398338343 ]
def resolve_issues(self, type): self.issues.filter(type=type, resolved_at=None).update(resolved_at=timezone.now())
AllMyChanges/allmychanges.com
[ 3, 1, 3, 18, 1398338343 ]
def set_status(self, status, **kwargs): changed_fields = ['status', 'updated_at'] if status == 'error': self.problem = kwargs.get('problem') changed_fields.append('problem') self.status = status self.updated_at = timezone.now() self.save(update_fields=cha...
AllMyChanges/allmychanges.com
[ 3, 1, 3, 18, 1398338343 ]
def get_processing_status(self): key = 'preview-processing-status:{0}'.format(self.id) result = cache.get(key, self.processing_status) return result
AllMyChanges/allmychanges.com
[ 3, 1, 3, 18, 1398338343 ]
def calc_next_update_if_error(self): # TODO: check and remove return timezone.now() + datetime.timedelta(0, 1 * 60 * 60)
AllMyChanges/allmychanges.com
[ 3, 1, 3, 18, 1398338343 ]
def resume(self): self.paused_at = None self.next_update_at = timezone.now() # we don't need to save here, because this will be done in schedule_update self.schedule_update()
AllMyChanges/allmychanges.com
[ 3, 1, 3, 18, 1398338343 ]
def update_description_from_source(self, fall_asleep_on_rate_limit=False): # right now this works only for github urls if 'github.com' not in self.source: return url, username, repo = normalize_url(self.source) url = 'https://api.github.com/repos/{0}/{1}'.format(username, re...
AllMyChanges/allmychanges.com
[ 3, 1, 3, 18, 1398338343 ]
def merge_into(self, to_ch): # move trackers to_ch_trackers = set(to_ch.trackers.values_list('id', flat=True)) for user in self.trackers.all(): if user.id not in to_ch_trackers: ChangelogTrack.objects.create(user=user, changelog=to_ch) action = 'moved...
AllMyChanges/allmychanges.com
[ 3, 1, 3, 18, 1398338343 ]
def remove_tag(self, user, name): """Removes tag with `name` on the version. """ self.tags.filter(user=user, name=name).delete()
AllMyChanges/allmychanges.com
[ 3, 1, 3, 18, 1398338343 ]
def save(self, *args, **kwargs): if not self.importance: self.importance = calculate_issue_importance( num_trackers=self.changelog.trackers.count() if self.changelog else 0, user=self.user, ligh...
AllMyChanges/allmychanges.com
[ 3, 1, 3, 18, 1398338343 ]
def merge(user, light_user): entries = Issue.objects.filter(user=None, light_user=light_user) if entries.count() > 0: with log.fields(username=user.username, num_entries=entries.count(), l...
AllMyChanges/allmychanges.com
[ 3, 1, 3, 18, 1398338343 ]
def get_related_versions(self): response = [version.strip() for version in self.related_versions.split(',')] return filter(None, response)
AllMyChanges/allmychanges.com
[ 3, 1, 3, 18, 1398338343 ]