def forwards(self, orm): for asset in orm.Asset.objects.filter(slug=''): other_assets = orm.Asset.objects.all() len = 14 while True: slug = passogva.generate_password(len, len) len += 1 if not other_assets.filter(slug=slug).exists(): break asset.slug = slug asset.save()
def PerPassogva( self ): BasedPassogva=passogva.generate_password( self.VDict['IntMin'], self.VDict['IntMax'] )[1].replace('-',' ') if self.VDict['random']: BasedPassogvaList=BasedPassogva.split( ' ' ) NewPassogvaNumVariant=str() for ItemCount in range( 0 , len( BasedPassogvaList )-1 ): NewPassogvaNumVariant += "%s%s" % ( BasedPassogvaList[ItemCount], self.GenerateRandomNumber() ) self.PassogvaStream=NewPassogvaNumVariant else: self.PassogvaStream=BasedPassogva self.FilterNoSpace()
def generate_slug(self): other_assets = Asset.objects.exclude(id=self.id) if self.pk else Asset.objects.all() log.debug('Generating slug for %r', self) slugstem = '' if self.title: slugstem = slugify(self.title) if slugstem: log.debug(' Generated slug stem from title') if not slugstem and self.summary: slugstem = slugify(truncatewords(self.summary, 10)) if slugstem: log.debug(' Generated slug stem from summary') if not slugstem and self.content: slugstem = slugify(truncatewords(striptags(self.content), 10)) if slugstem: log.debug(' Generated slug stem from content') if slugstem: log.debug(' Content yielded a slugstem of %r! Building slug from it', slugstem) slug = slugstem i = 1 while other_assets.filter(slug=slug).exists(): slug = '%s-%d' % (slugstem, i) i += 1 else: log.debug(' Asset has no content, so generating a random slug') len = 14 while True: slug, dashed_slug = passogva.generate_password(len, len) len += 1 if not other_assets.filter(slug=slug).exists(): break log.debug(' Generated slug %r', slug) self.slug = slug
def RandomParamMaker( defaultMinArg=3 , defaultMaxArg=6 , MaxLengthDict=5 , MinDistancePair=3 , DefaultDecreaseMaxArgFactor=100 , DefaultMaxFactorReg=5 , MaxArgFactorInfl=10 ): ParamDict=dict() CountInnerLoop=0 CountPerInflation=0 if defaultMaxArg-defaultMinArg < MinDistancePair: defaultMaxArg=defaultMaxArg+ MinDistancePair SaveMaxArg=defaultMaxArg SaveMinArg=defaultMinArg while len( ParamDict.keys() ) <= MaxLengthDict: TupleParam=passogva.generate_password( minlen=defaultMinArg, maxlen=defaultMaxArg ) ListParam=TupleParam[1].split('-') for Item in ListParam: if len( Item ) >= defaultMinArg: StreamVariableReduc=str( uuid4() ).replace( '-', '' ) * 5 StartCopyPart=0 EndCopyPart=random.randint( 1, len( StreamVariableReduc )-1 ) ParamDict[Item]=StreamVariableReduc[StartCopyPart:EndCopyPart] if CountInnerLoop >= DefaultDecreaseMaxArgFactor: print "Present Pair Value <<%d, %d >> exceed DecreaseMaxArgFactor : %d \n\tCurrent DictKey:[ %s ]" % ( defaultMinArg , defaultMaxArg, DefaultDecreaseMaxArgFactor, ParamDict.keys() ) if defaultMinArg >= defaultMaxArg: SaveMinArg+=1 SaveMaxArg+=1 defaultMinArg=SaveMinArg defaultMaxArg=SaveMaxArg defaultMinArg+=1 CountInnerLoop=0 CountPerInflation+=1 if CountPerInflation == DefaultMaxFactorReg: DefaultDecreaseMaxArgFactor+=MaxArgFactorInfl if ( ( defaultMinArg-(MaxArgFactorInfl / 2) ) > 0 ) and ( ( defaultMinArg-( MaxArgFactorInfl / 2 ) < defaultMaxArg ) ): defaultMinArg=( defaultMinArg - ( MaxArgFactorInfl / 2 ) ) CountPerInflation=0 CountInnerLoop+=1 print "Returned Dict:[ %s ]" % ( ParamDict.keys() ) return ParamDict