prompt
large_stringlengths 72
9.34k
| completion
large_stringlengths 0
7.61k
|
---|---|
<|file_name|>mallet_lda_tags.py<|end_file_name|><|fim▁begin|>#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import os
import logging
import traceback
import mallet_lda
class MalletTagTopics(mallet_lda.MalletLDA):
"""
Topic modeling with separation based on tags
"""
def _basic_params(self):
self.name = 'mallet_lda_tags'
self.categorical = False
self.template_name = 'mallet_lda'
self.dry_run = False
self.topics = 50
self.dfr = len(self.extra_args) > 0
if self.dfr:
self.dfr_dir = self.extra_args[0]
def <|fim_middle|>(self):
if self.named_args is not None:
if 'tags' in self.named_args:
self.tags = self.named_args['tags']
for filename in self.metadata.keys():
my_tags = [x for (x, y) in self.tags.iteritems()
if int(self.metadata[filename]['itemID'
]) in y]
if len(my_tags) > 0:
self.metadata[filename]['label'] = my_tags[0]
else:
del self.metadata[filename]
self.files.remove(filename)
if __name__ == '__main__':
try:
processor = MalletTagTopics(track_progress=False)
processor.process()
except:
logging.error(traceback.format_exc())
<|fim▁end|> | post_setup |
<|file_name|>urls.py<|end_file_name|><|fim▁begin|>"""course_discovery URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/1.8/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
Including another URLconf
1. Add an import: from blog import urls as blog_urls
2. Add a URL to urlpatterns: url(r'^blog/', include(blog_urls))
"""
import os
from django.conf import settings
from django.conf.urls import include, url
from django.contrib import admin
from django.contrib.auth.views import logout
from django.core.urlresolvers import reverse_lazy
from django.views.generic import RedirectView
from course_discovery.apps.core import views as core_views
admin.autodiscover()
# pylint: disable=invalid-name
# Always login via edX OpenID Connect<|fim▁hole|>
urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
url(r'^api/', include('course_discovery.apps.api.urls', namespace='api')),
url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')),
url(r'^auto_auth/$', core_views.AutoAuth.as_view(), name='auto_auth'),
url(r'^health/$', core_views.health, name='health'),
url(r'^login/$', login, name='login'),
url(r'^logout/$', logout, name='logout'),
url('', include('social.apps.django_app.urls', namespace='social')),
]
if settings.DEBUG and os.environ.get('ENABLE_DJANGO_TOOLBAR', False): # pragma: no cover
import debug_toolbar # pylint: disable=import-error
urlpatterns.append(url(r'^__debug__/', include(debug_toolbar.urls)))<|fim▁end|> | login = RedirectView.as_view(url=reverse_lazy('social:begin', args=['edx-oidc']), permanent=False, query_string=True) |
<|file_name|>urls.py<|end_file_name|><|fim▁begin|>"""course_discovery URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/1.8/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
Including another URLconf
1. Add an import: from blog import urls as blog_urls
2. Add a URL to urlpatterns: url(r'^blog/', include(blog_urls))
"""
import os
from django.conf import settings
from django.conf.urls import include, url
from django.contrib import admin
from django.contrib.auth.views import logout
from django.core.urlresolvers import reverse_lazy
from django.views.generic import RedirectView
from course_discovery.apps.core import views as core_views
admin.autodiscover()
# pylint: disable=invalid-name
# Always login via edX OpenID Connect
login = RedirectView.as_view(url=reverse_lazy('social:begin', args=['edx-oidc']), permanent=False, query_string=True)
urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
url(r'^api/', include('course_discovery.apps.api.urls', namespace='api')),
url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')),
url(r'^auto_auth/$', core_views.AutoAuth.as_view(), name='auto_auth'),
url(r'^health/$', core_views.health, name='health'),
url(r'^login/$', login, name='login'),
url(r'^logout/$', logout, name='logout'),
url('', include('social.apps.django_app.urls', namespace='social')),
]
if settings.DEBUG and os.environ.get('ENABLE_DJANGO_TOOLBAR', False): # pragma: no cover
<|fim_middle|>
<|fim▁end|> | import debug_toolbar # pylint: disable=import-error
urlpatterns.append(url(r'^__debug__/', include(debug_toolbar.urls))) |
<|file_name|>opening_a_file.py<|end_file_name|><|fim▁begin|>#
# Place a file called test.txt in the same directory as you place this program... <|fim▁hole|>#
f = open('test.txt')
s = f.read()
print(s)<|fim▁end|> | |
<|file_name|>KPassivePopupMessageHandler.py<|end_file_name|><|fim▁begin|># encoding: utf-8
# module PyKDE4.kdeui
# from /usr/lib/python3/dist-packages/PyKDE4/kdeui.cpython-34m-x86_64-linux-gnu.so
# by generator 1.135
# no doc
# imports
import PyKDE4.kdecore as __PyKDE4_kdecore
import PyQt4.QtCore as __PyQt4_QtCore
import PyQt4.QtGui as __PyQt4_QtGui
import PyQt4.QtSvg as __PyQt4_QtSvg
class KPassivePopupMessageHandler(__PyQt4_QtCore.QObject, __PyKDE4_kdecore.KMessageHandler):
# no doc
def message(self, *args, **kwargs): # real signature unknown
pass
<|fim▁hole|> pass<|fim▁end|> | def __init__(self, *args, **kwargs): # real signature unknown |
<|file_name|>KPassivePopupMessageHandler.py<|end_file_name|><|fim▁begin|># encoding: utf-8
# module PyKDE4.kdeui
# from /usr/lib/python3/dist-packages/PyKDE4/kdeui.cpython-34m-x86_64-linux-gnu.so
# by generator 1.135
# no doc
# imports
import PyKDE4.kdecore as __PyKDE4_kdecore
import PyQt4.QtCore as __PyQt4_QtCore
import PyQt4.QtGui as __PyQt4_QtGui
import PyQt4.QtSvg as __PyQt4_QtSvg
class KPassivePopupMessageHandler(__PyQt4_QtCore.QObject, __PyKDE4_kdecore.KMessageHandler):
# no doc
<|fim_middle|>
<|fim▁end|> | def message(self, *args, **kwargs): # real signature unknown
pass
def __init__(self, *args, **kwargs): # real signature unknown
pass |
<|file_name|>KPassivePopupMessageHandler.py<|end_file_name|><|fim▁begin|># encoding: utf-8
# module PyKDE4.kdeui
# from /usr/lib/python3/dist-packages/PyKDE4/kdeui.cpython-34m-x86_64-linux-gnu.so
# by generator 1.135
# no doc
# imports
import PyKDE4.kdecore as __PyKDE4_kdecore
import PyQt4.QtCore as __PyQt4_QtCore
import PyQt4.QtGui as __PyQt4_QtGui
import PyQt4.QtSvg as __PyQt4_QtSvg
class KPassivePopupMessageHandler(__PyQt4_QtCore.QObject, __PyKDE4_kdecore.KMessageHandler):
# no doc
def message(self, *args, **kwargs): # real signature unknown
<|fim_middle|>
def __init__(self, *args, **kwargs): # real signature unknown
pass
<|fim▁end|> | pass |
<|file_name|>KPassivePopupMessageHandler.py<|end_file_name|><|fim▁begin|># encoding: utf-8
# module PyKDE4.kdeui
# from /usr/lib/python3/dist-packages/PyKDE4/kdeui.cpython-34m-x86_64-linux-gnu.so
# by generator 1.135
# no doc
# imports
import PyKDE4.kdecore as __PyKDE4_kdecore
import PyQt4.QtCore as __PyQt4_QtCore
import PyQt4.QtGui as __PyQt4_QtGui
import PyQt4.QtSvg as __PyQt4_QtSvg
class KPassivePopupMessageHandler(__PyQt4_QtCore.QObject, __PyKDE4_kdecore.KMessageHandler):
# no doc
def message(self, *args, **kwargs): # real signature unknown
pass
def __init__(self, *args, **kwargs): # real signature unknown
<|fim_middle|>
<|fim▁end|> | pass |
<|file_name|>KPassivePopupMessageHandler.py<|end_file_name|><|fim▁begin|># encoding: utf-8
# module PyKDE4.kdeui
# from /usr/lib/python3/dist-packages/PyKDE4/kdeui.cpython-34m-x86_64-linux-gnu.so
# by generator 1.135
# no doc
# imports
import PyKDE4.kdecore as __PyKDE4_kdecore
import PyQt4.QtCore as __PyQt4_QtCore
import PyQt4.QtGui as __PyQt4_QtGui
import PyQt4.QtSvg as __PyQt4_QtSvg
class KPassivePopupMessageHandler(__PyQt4_QtCore.QObject, __PyKDE4_kdecore.KMessageHandler):
# no doc
def <|fim_middle|>(self, *args, **kwargs): # real signature unknown
pass
def __init__(self, *args, **kwargs): # real signature unknown
pass
<|fim▁end|> | message |
<|file_name|>KPassivePopupMessageHandler.py<|end_file_name|><|fim▁begin|># encoding: utf-8
# module PyKDE4.kdeui
# from /usr/lib/python3/dist-packages/PyKDE4/kdeui.cpython-34m-x86_64-linux-gnu.so
# by generator 1.135
# no doc
# imports
import PyKDE4.kdecore as __PyKDE4_kdecore
import PyQt4.QtCore as __PyQt4_QtCore
import PyQt4.QtGui as __PyQt4_QtGui
import PyQt4.QtSvg as __PyQt4_QtSvg
class KPassivePopupMessageHandler(__PyQt4_QtCore.QObject, __PyKDE4_kdecore.KMessageHandler):
# no doc
def message(self, *args, **kwargs): # real signature unknown
pass
def <|fim_middle|>(self, *args, **kwargs): # real signature unknown
pass
<|fim▁end|> | __init__ |
<|file_name|>wl.py<|end_file_name|><|fim▁begin|>import pyautogui, win32api, win32con, ctypes, autoit
from PIL import ImageOps, Image, ImageGrab
from numpy import *
import os
import time
import cv2
import random
from Bot import *
def main():
bot = Bot()
autoit.win_wait(bot.title, 5)
counter = 0
poitonUse = 0
cycle = True
fullCounter = 0
while cycle:
hpstatus = bot.checkOwnHp()
print 'hp ' + str(hpstatus)
if hpstatus == 0:
autoit.control_send(bot.title, '', '{F9}', 0)
bot.sleep(0.3,0.6)
print 'Dead'
cv2.imwrite('Dead' + str(int(time.time())) + '.png',bot.getScreen(leftCornerx,leftCornery,x2,fullY2))
cycle = False
if hpstatus == 1:
if poitonUse == 0:
autoit.control_send(bot.title, '', '{F10}', 0)
poitonUse += 1
if poitonUse > 5:
poitonUse = 0
else:
poitonUse = 0
res = bot.findHP();
print 'tgs ' + str(res)
if res == 3:
fullCounter += 1
print 'fc ' + str(fullCounter)
autoit.control_send(bot.title, '', '{F1}', 0)
else:
fullCounter = 0
if fullCounter > 4:
autoit.control_send(bot.title, '', '{ESC}', 0)
bot.sleep(0.3,0.6)
autoit.control_send(bot.title, '', '{F3}', 0)
bot.sleep(0.1,0.3)
autoit.control_send(bot.title, '', '{F1}', 0)
# bot.mouseRotate()
fullCounter = 0
if res > 0:
autoit.control_send(bot.title, '', '{F1}', 0)
counter = 0
if res == 1 or res == 3:
bot.sleep(0.3,0.6)
if res > 1 and res < 3:
bot.sleep(1,3)
if res == 1:
autoit.control_send(bot.title, '', '{F3}', 0)
bot.sleep(0.3,0.6)
autoit.control_send(bot.title, '', '{F2}', 0)
bot.sleep(0.3,0.6)
autoit.control_send(bot.title, '', '{F1}', 0)
else:
fullCounter = 0
if counter < 3:
autoit.control_send(bot.title, '', '{F3}', 0)
bot.sleep(0.5,0.8)
autoit.control_send(bot.title, '', '{F1}', 0)
print 'F3'
if counter > 2:
# bot.findTarget()
autoit.control_send(bot.title, '', '{F7}', 0)
# if counter > 3:<|fim▁hole|> pass
if __name__ == '__main__':
main()<|fim▁end|> | # autoit.control_send(bot.title, '', '{F8}', 0)
# counter = 0
counter += 1
print 'cnt ' + str(counter) |
<|file_name|>wl.py<|end_file_name|><|fim▁begin|>import pyautogui, win32api, win32con, ctypes, autoit
from PIL import ImageOps, Image, ImageGrab
from numpy import *
import os
import time
import cv2
import random
from Bot import *
def main():
<|fim_middle|>
if __name__ == '__main__':
main()
<|fim▁end|> | bot = Bot()
autoit.win_wait(bot.title, 5)
counter = 0
poitonUse = 0
cycle = True
fullCounter = 0
while cycle:
hpstatus = bot.checkOwnHp()
print 'hp ' + str(hpstatus)
if hpstatus == 0:
autoit.control_send(bot.title, '', '{F9}', 0)
bot.sleep(0.3,0.6)
print 'Dead'
cv2.imwrite('Dead' + str(int(time.time())) + '.png',bot.getScreen(leftCornerx,leftCornery,x2,fullY2))
cycle = False
if hpstatus == 1:
if poitonUse == 0:
autoit.control_send(bot.title, '', '{F10}', 0)
poitonUse += 1
if poitonUse > 5:
poitonUse = 0
else:
poitonUse = 0
res = bot.findHP();
print 'tgs ' + str(res)
if res == 3:
fullCounter += 1
print 'fc ' + str(fullCounter)
autoit.control_send(bot.title, '', '{F1}', 0)
else:
fullCounter = 0
if fullCounter > 4:
autoit.control_send(bot.title, '', '{ESC}', 0)
bot.sleep(0.3,0.6)
autoit.control_send(bot.title, '', '{F3}', 0)
bot.sleep(0.1,0.3)
autoit.control_send(bot.title, '', '{F1}', 0)
# bot.mouseRotate()
fullCounter = 0
if res > 0:
autoit.control_send(bot.title, '', '{F1}', 0)
counter = 0
if res == 1 or res == 3:
bot.sleep(0.3,0.6)
if res > 1 and res < 3:
bot.sleep(1,3)
if res == 1:
autoit.control_send(bot.title, '', '{F3}', 0)
bot.sleep(0.3,0.6)
autoit.control_send(bot.title, '', '{F2}', 0)
bot.sleep(0.3,0.6)
autoit.control_send(bot.title, '', '{F1}', 0)
else:
fullCounter = 0
if counter < 3:
autoit.control_send(bot.title, '', '{F3}', 0)
bot.sleep(0.5,0.8)
autoit.control_send(bot.title, '', '{F1}', 0)
print 'F3'
if counter > 2:
# bot.findTarget()
autoit.control_send(bot.title, '', '{F7}', 0)
# if counter > 3:
# autoit.control_send(bot.title, '', '{F8}', 0)
# counter = 0
counter += 1
print 'cnt ' + str(counter)
pass |
<|file_name|>wl.py<|end_file_name|><|fim▁begin|>import pyautogui, win32api, win32con, ctypes, autoit
from PIL import ImageOps, Image, ImageGrab
from numpy import *
import os
import time
import cv2
import random
from Bot import *
def main():
bot = Bot()
autoit.win_wait(bot.title, 5)
counter = 0
poitonUse = 0
cycle = True
fullCounter = 0
while cycle:
hpstatus = bot.checkOwnHp()
print 'hp ' + str(hpstatus)
if hpstatus == 0:
<|fim_middle|>
if hpstatus == 1:
if poitonUse == 0:
autoit.control_send(bot.title, '', '{F10}', 0)
poitonUse += 1
if poitonUse > 5:
poitonUse = 0
else:
poitonUse = 0
res = bot.findHP();
print 'tgs ' + str(res)
if res == 3:
fullCounter += 1
print 'fc ' + str(fullCounter)
autoit.control_send(bot.title, '', '{F1}', 0)
else:
fullCounter = 0
if fullCounter > 4:
autoit.control_send(bot.title, '', '{ESC}', 0)
bot.sleep(0.3,0.6)
autoit.control_send(bot.title, '', '{F3}', 0)
bot.sleep(0.1,0.3)
autoit.control_send(bot.title, '', '{F1}', 0)
# bot.mouseRotate()
fullCounter = 0
if res > 0:
autoit.control_send(bot.title, '', '{F1}', 0)
counter = 0
if res == 1 or res == 3:
bot.sleep(0.3,0.6)
if res > 1 and res < 3:
bot.sleep(1,3)
if res == 1:
autoit.control_send(bot.title, '', '{F3}', 0)
bot.sleep(0.3,0.6)
autoit.control_send(bot.title, '', '{F2}', 0)
bot.sleep(0.3,0.6)
autoit.control_send(bot.title, '', '{F1}', 0)
else:
fullCounter = 0
if counter < 3:
autoit.control_send(bot.title, '', '{F3}', 0)
bot.sleep(0.5,0.8)
autoit.control_send(bot.title, '', '{F1}', 0)
print 'F3'
if counter > 2:
# bot.findTarget()
autoit.control_send(bot.title, '', '{F7}', 0)
# if counter > 3:
# autoit.control_send(bot.title, '', '{F8}', 0)
# counter = 0
counter += 1
print 'cnt ' + str(counter)
pass
if __name__ == '__main__':
main()
<|fim▁end|> | autoit.control_send(bot.title, '', '{F9}', 0)
bot.sleep(0.3,0.6)
print 'Dead'
cv2.imwrite('Dead' + str(int(time.time())) + '.png',bot.getScreen(leftCornerx,leftCornery,x2,fullY2))
cycle = False |
<|file_name|>wl.py<|end_file_name|><|fim▁begin|>import pyautogui, win32api, win32con, ctypes, autoit
from PIL import ImageOps, Image, ImageGrab
from numpy import *
import os
import time
import cv2
import random
from Bot import *
def main():
bot = Bot()
autoit.win_wait(bot.title, 5)
counter = 0
poitonUse = 0
cycle = True
fullCounter = 0
while cycle:
hpstatus = bot.checkOwnHp()
print 'hp ' + str(hpstatus)
if hpstatus == 0:
autoit.control_send(bot.title, '', '{F9}', 0)
bot.sleep(0.3,0.6)
print 'Dead'
cv2.imwrite('Dead' + str(int(time.time())) + '.png',bot.getScreen(leftCornerx,leftCornery,x2,fullY2))
cycle = False
if hpstatus == 1:
<|fim_middle|>
else:
poitonUse = 0
res = bot.findHP();
print 'tgs ' + str(res)
if res == 3:
fullCounter += 1
print 'fc ' + str(fullCounter)
autoit.control_send(bot.title, '', '{F1}', 0)
else:
fullCounter = 0
if fullCounter > 4:
autoit.control_send(bot.title, '', '{ESC}', 0)
bot.sleep(0.3,0.6)
autoit.control_send(bot.title, '', '{F3}', 0)
bot.sleep(0.1,0.3)
autoit.control_send(bot.title, '', '{F1}', 0)
# bot.mouseRotate()
fullCounter = 0
if res > 0:
autoit.control_send(bot.title, '', '{F1}', 0)
counter = 0
if res == 1 or res == 3:
bot.sleep(0.3,0.6)
if res > 1 and res < 3:
bot.sleep(1,3)
if res == 1:
autoit.control_send(bot.title, '', '{F3}', 0)
bot.sleep(0.3,0.6)
autoit.control_send(bot.title, '', '{F2}', 0)
bot.sleep(0.3,0.6)
autoit.control_send(bot.title, '', '{F1}', 0)
else:
fullCounter = 0
if counter < 3:
autoit.control_send(bot.title, '', '{F3}', 0)
bot.sleep(0.5,0.8)
autoit.control_send(bot.title, '', '{F1}', 0)
print 'F3'
if counter > 2:
# bot.findTarget()
autoit.control_send(bot.title, '', '{F7}', 0)
# if counter > 3:
# autoit.control_send(bot.title, '', '{F8}', 0)
# counter = 0
counter += 1
print 'cnt ' + str(counter)
pass
if __name__ == '__main__':
main()
<|fim▁end|> | if poitonUse == 0:
autoit.control_send(bot.title, '', '{F10}', 0)
poitonUse += 1
if poitonUse > 5:
poitonUse = 0 |
<|file_name|>wl.py<|end_file_name|><|fim▁begin|>import pyautogui, win32api, win32con, ctypes, autoit
from PIL import ImageOps, Image, ImageGrab
from numpy import *
import os
import time
import cv2
import random
from Bot import *
def main():
bot = Bot()
autoit.win_wait(bot.title, 5)
counter = 0
poitonUse = 0
cycle = True
fullCounter = 0
while cycle:
hpstatus = bot.checkOwnHp()
print 'hp ' + str(hpstatus)
if hpstatus == 0:
autoit.control_send(bot.title, '', '{F9}', 0)
bot.sleep(0.3,0.6)
print 'Dead'
cv2.imwrite('Dead' + str(int(time.time())) + '.png',bot.getScreen(leftCornerx,leftCornery,x2,fullY2))
cycle = False
if hpstatus == 1:
if poitonUse == 0:
<|fim_middle|>
poitonUse += 1
if poitonUse > 5:
poitonUse = 0
else:
poitonUse = 0
res = bot.findHP();
print 'tgs ' + str(res)
if res == 3:
fullCounter += 1
print 'fc ' + str(fullCounter)
autoit.control_send(bot.title, '', '{F1}', 0)
else:
fullCounter = 0
if fullCounter > 4:
autoit.control_send(bot.title, '', '{ESC}', 0)
bot.sleep(0.3,0.6)
autoit.control_send(bot.title, '', '{F3}', 0)
bot.sleep(0.1,0.3)
autoit.control_send(bot.title, '', '{F1}', 0)
# bot.mouseRotate()
fullCounter = 0
if res > 0:
autoit.control_send(bot.title, '', '{F1}', 0)
counter = 0
if res == 1 or res == 3:
bot.sleep(0.3,0.6)
if res > 1 and res < 3:
bot.sleep(1,3)
if res == 1:
autoit.control_send(bot.title, '', '{F3}', 0)
bot.sleep(0.3,0.6)
autoit.control_send(bot.title, '', '{F2}', 0)
bot.sleep(0.3,0.6)
autoit.control_send(bot.title, '', '{F1}', 0)
else:
fullCounter = 0
if counter < 3:
autoit.control_send(bot.title, '', '{F3}', 0)
bot.sleep(0.5,0.8)
autoit.control_send(bot.title, '', '{F1}', 0)
print 'F3'
if counter > 2:
# bot.findTarget()
autoit.control_send(bot.title, '', '{F7}', 0)
# if counter > 3:
# autoit.control_send(bot.title, '', '{F8}', 0)
# counter = 0
counter += 1
print 'cnt ' + str(counter)
pass
if __name__ == '__main__':
main()
<|fim▁end|> | autoit.control_send(bot.title, '', '{F10}', 0) |
<|file_name|>wl.py<|end_file_name|><|fim▁begin|>import pyautogui, win32api, win32con, ctypes, autoit
from PIL import ImageOps, Image, ImageGrab
from numpy import *
import os
import time
import cv2
import random
from Bot import *
def main():
bot = Bot()
autoit.win_wait(bot.title, 5)
counter = 0
poitonUse = 0
cycle = True
fullCounter = 0
while cycle:
hpstatus = bot.checkOwnHp()
print 'hp ' + str(hpstatus)
if hpstatus == 0:
autoit.control_send(bot.title, '', '{F9}', 0)
bot.sleep(0.3,0.6)
print 'Dead'
cv2.imwrite('Dead' + str(int(time.time())) + '.png',bot.getScreen(leftCornerx,leftCornery,x2,fullY2))
cycle = False
if hpstatus == 1:
if poitonUse == 0:
autoit.control_send(bot.title, '', '{F10}', 0)
poitonUse += 1
if poitonUse > 5:
<|fim_middle|>
else:
poitonUse = 0
res = bot.findHP();
print 'tgs ' + str(res)
if res == 3:
fullCounter += 1
print 'fc ' + str(fullCounter)
autoit.control_send(bot.title, '', '{F1}', 0)
else:
fullCounter = 0
if fullCounter > 4:
autoit.control_send(bot.title, '', '{ESC}', 0)
bot.sleep(0.3,0.6)
autoit.control_send(bot.title, '', '{F3}', 0)
bot.sleep(0.1,0.3)
autoit.control_send(bot.title, '', '{F1}', 0)
# bot.mouseRotate()
fullCounter = 0
if res > 0:
autoit.control_send(bot.title, '', '{F1}', 0)
counter = 0
if res == 1 or res == 3:
bot.sleep(0.3,0.6)
if res > 1 and res < 3:
bot.sleep(1,3)
if res == 1:
autoit.control_send(bot.title, '', '{F3}', 0)
bot.sleep(0.3,0.6)
autoit.control_send(bot.title, '', '{F2}', 0)
bot.sleep(0.3,0.6)
autoit.control_send(bot.title, '', '{F1}', 0)
else:
fullCounter = 0
if counter < 3:
autoit.control_send(bot.title, '', '{F3}', 0)
bot.sleep(0.5,0.8)
autoit.control_send(bot.title, '', '{F1}', 0)
print 'F3'
if counter > 2:
# bot.findTarget()
autoit.control_send(bot.title, '', '{F7}', 0)
# if counter > 3:
# autoit.control_send(bot.title, '', '{F8}', 0)
# counter = 0
counter += 1
print 'cnt ' + str(counter)
pass
if __name__ == '__main__':
main()
<|fim▁end|> | poitonUse = 0 |
<|file_name|>wl.py<|end_file_name|><|fim▁begin|>import pyautogui, win32api, win32con, ctypes, autoit
from PIL import ImageOps, Image, ImageGrab
from numpy import *
import os
import time
import cv2
import random
from Bot import *
def main():
bot = Bot()
autoit.win_wait(bot.title, 5)
counter = 0
poitonUse = 0
cycle = True
fullCounter = 0
while cycle:
hpstatus = bot.checkOwnHp()
print 'hp ' + str(hpstatus)
if hpstatus == 0:
autoit.control_send(bot.title, '', '{F9}', 0)
bot.sleep(0.3,0.6)
print 'Dead'
cv2.imwrite('Dead' + str(int(time.time())) + '.png',bot.getScreen(leftCornerx,leftCornery,x2,fullY2))
cycle = False
if hpstatus == 1:
if poitonUse == 0:
autoit.control_send(bot.title, '', '{F10}', 0)
poitonUse += 1
if poitonUse > 5:
poitonUse = 0
else:
<|fim_middle|>
res = bot.findHP();
print 'tgs ' + str(res)
if res == 3:
fullCounter += 1
print 'fc ' + str(fullCounter)
autoit.control_send(bot.title, '', '{F1}', 0)
else:
fullCounter = 0
if fullCounter > 4:
autoit.control_send(bot.title, '', '{ESC}', 0)
bot.sleep(0.3,0.6)
autoit.control_send(bot.title, '', '{F3}', 0)
bot.sleep(0.1,0.3)
autoit.control_send(bot.title, '', '{F1}', 0)
# bot.mouseRotate()
fullCounter = 0
if res > 0:
autoit.control_send(bot.title, '', '{F1}', 0)
counter = 0
if res == 1 or res == 3:
bot.sleep(0.3,0.6)
if res > 1 and res < 3:
bot.sleep(1,3)
if res == 1:
autoit.control_send(bot.title, '', '{F3}', 0)
bot.sleep(0.3,0.6)
autoit.control_send(bot.title, '', '{F2}', 0)
bot.sleep(0.3,0.6)
autoit.control_send(bot.title, '', '{F1}', 0)
else:
fullCounter = 0
if counter < 3:
autoit.control_send(bot.title, '', '{F3}', 0)
bot.sleep(0.5,0.8)
autoit.control_send(bot.title, '', '{F1}', 0)
print 'F3'
if counter > 2:
# bot.findTarget()
autoit.control_send(bot.title, '', '{F7}', 0)
# if counter > 3:
# autoit.control_send(bot.title, '', '{F8}', 0)
# counter = 0
counter += 1
print 'cnt ' + str(counter)
pass
if __name__ == '__main__':
main()
<|fim▁end|> | poitonUse = 0 |
<|file_name|>wl.py<|end_file_name|><|fim▁begin|>import pyautogui, win32api, win32con, ctypes, autoit
from PIL import ImageOps, Image, ImageGrab
from numpy import *
import os
import time
import cv2
import random
from Bot import *
def main():
bot = Bot()
autoit.win_wait(bot.title, 5)
counter = 0
poitonUse = 0
cycle = True
fullCounter = 0
while cycle:
hpstatus = bot.checkOwnHp()
print 'hp ' + str(hpstatus)
if hpstatus == 0:
autoit.control_send(bot.title, '', '{F9}', 0)
bot.sleep(0.3,0.6)
print 'Dead'
cv2.imwrite('Dead' + str(int(time.time())) + '.png',bot.getScreen(leftCornerx,leftCornery,x2,fullY2))
cycle = False
if hpstatus == 1:
if poitonUse == 0:
autoit.control_send(bot.title, '', '{F10}', 0)
poitonUse += 1
if poitonUse > 5:
poitonUse = 0
else:
poitonUse = 0
res = bot.findHP();
print 'tgs ' + str(res)
if res == 3:
<|fim_middle|>
else:
fullCounter = 0
if fullCounter > 4:
autoit.control_send(bot.title, '', '{ESC}', 0)
bot.sleep(0.3,0.6)
autoit.control_send(bot.title, '', '{F3}', 0)
bot.sleep(0.1,0.3)
autoit.control_send(bot.title, '', '{F1}', 0)
# bot.mouseRotate()
fullCounter = 0
if res > 0:
autoit.control_send(bot.title, '', '{F1}', 0)
counter = 0
if res == 1 or res == 3:
bot.sleep(0.3,0.6)
if res > 1 and res < 3:
bot.sleep(1,3)
if res == 1:
autoit.control_send(bot.title, '', '{F3}', 0)
bot.sleep(0.3,0.6)
autoit.control_send(bot.title, '', '{F2}', 0)
bot.sleep(0.3,0.6)
autoit.control_send(bot.title, '', '{F1}', 0)
else:
fullCounter = 0
if counter < 3:
autoit.control_send(bot.title, '', '{F3}', 0)
bot.sleep(0.5,0.8)
autoit.control_send(bot.title, '', '{F1}', 0)
print 'F3'
if counter > 2:
# bot.findTarget()
autoit.control_send(bot.title, '', '{F7}', 0)
# if counter > 3:
# autoit.control_send(bot.title, '', '{F8}', 0)
# counter = 0
counter += 1
print 'cnt ' + str(counter)
pass
if __name__ == '__main__':
main()
<|fim▁end|> | fullCounter += 1
print 'fc ' + str(fullCounter)
autoit.control_send(bot.title, '', '{F1}', 0) |
<|file_name|>wl.py<|end_file_name|><|fim▁begin|>import pyautogui, win32api, win32con, ctypes, autoit
from PIL import ImageOps, Image, ImageGrab
from numpy import *
import os
import time
import cv2
import random
from Bot import *
def main():
bot = Bot()
autoit.win_wait(bot.title, 5)
counter = 0
poitonUse = 0
cycle = True
fullCounter = 0
while cycle:
hpstatus = bot.checkOwnHp()
print 'hp ' + str(hpstatus)
if hpstatus == 0:
autoit.control_send(bot.title, '', '{F9}', 0)
bot.sleep(0.3,0.6)
print 'Dead'
cv2.imwrite('Dead' + str(int(time.time())) + '.png',bot.getScreen(leftCornerx,leftCornery,x2,fullY2))
cycle = False
if hpstatus == 1:
if poitonUse == 0:
autoit.control_send(bot.title, '', '{F10}', 0)
poitonUse += 1
if poitonUse > 5:
poitonUse = 0
else:
poitonUse = 0
res = bot.findHP();
print 'tgs ' + str(res)
if res == 3:
fullCounter += 1
print 'fc ' + str(fullCounter)
autoit.control_send(bot.title, '', '{F1}', 0)
else:
<|fim_middle|>
if fullCounter > 4:
autoit.control_send(bot.title, '', '{ESC}', 0)
bot.sleep(0.3,0.6)
autoit.control_send(bot.title, '', '{F3}', 0)
bot.sleep(0.1,0.3)
autoit.control_send(bot.title, '', '{F1}', 0)
# bot.mouseRotate()
fullCounter = 0
if res > 0:
autoit.control_send(bot.title, '', '{F1}', 0)
counter = 0
if res == 1 or res == 3:
bot.sleep(0.3,0.6)
if res > 1 and res < 3:
bot.sleep(1,3)
if res == 1:
autoit.control_send(bot.title, '', '{F3}', 0)
bot.sleep(0.3,0.6)
autoit.control_send(bot.title, '', '{F2}', 0)
bot.sleep(0.3,0.6)
autoit.control_send(bot.title, '', '{F1}', 0)
else:
fullCounter = 0
if counter < 3:
autoit.control_send(bot.title, '', '{F3}', 0)
bot.sleep(0.5,0.8)
autoit.control_send(bot.title, '', '{F1}', 0)
print 'F3'
if counter > 2:
# bot.findTarget()
autoit.control_send(bot.title, '', '{F7}', 0)
# if counter > 3:
# autoit.control_send(bot.title, '', '{F8}', 0)
# counter = 0
counter += 1
print 'cnt ' + str(counter)
pass
if __name__ == '__main__':
main()
<|fim▁end|> | fullCounter = 0 |
<|file_name|>wl.py<|end_file_name|><|fim▁begin|>import pyautogui, win32api, win32con, ctypes, autoit
from PIL import ImageOps, Image, ImageGrab
from numpy import *
import os
import time
import cv2
import random
from Bot import *
def main():
bot = Bot()
autoit.win_wait(bot.title, 5)
counter = 0
poitonUse = 0
cycle = True
fullCounter = 0
while cycle:
hpstatus = bot.checkOwnHp()
print 'hp ' + str(hpstatus)
if hpstatus == 0:
autoit.control_send(bot.title, '', '{F9}', 0)
bot.sleep(0.3,0.6)
print 'Dead'
cv2.imwrite('Dead' + str(int(time.time())) + '.png',bot.getScreen(leftCornerx,leftCornery,x2,fullY2))
cycle = False
if hpstatus == 1:
if poitonUse == 0:
autoit.control_send(bot.title, '', '{F10}', 0)
poitonUse += 1
if poitonUse > 5:
poitonUse = 0
else:
poitonUse = 0
res = bot.findHP();
print 'tgs ' + str(res)
if res == 3:
fullCounter += 1
print 'fc ' + str(fullCounter)
autoit.control_send(bot.title, '', '{F1}', 0)
else:
fullCounter = 0
if fullCounter > 4:
<|fim_middle|>
if res > 0:
autoit.control_send(bot.title, '', '{F1}', 0)
counter = 0
if res == 1 or res == 3:
bot.sleep(0.3,0.6)
if res > 1 and res < 3:
bot.sleep(1,3)
if res == 1:
autoit.control_send(bot.title, '', '{F3}', 0)
bot.sleep(0.3,0.6)
autoit.control_send(bot.title, '', '{F2}', 0)
bot.sleep(0.3,0.6)
autoit.control_send(bot.title, '', '{F1}', 0)
else:
fullCounter = 0
if counter < 3:
autoit.control_send(bot.title, '', '{F3}', 0)
bot.sleep(0.5,0.8)
autoit.control_send(bot.title, '', '{F1}', 0)
print 'F3'
if counter > 2:
# bot.findTarget()
autoit.control_send(bot.title, '', '{F7}', 0)
# if counter > 3:
# autoit.control_send(bot.title, '', '{F8}', 0)
# counter = 0
counter += 1
print 'cnt ' + str(counter)
pass
if __name__ == '__main__':
main()
<|fim▁end|> | autoit.control_send(bot.title, '', '{ESC}', 0)
bot.sleep(0.3,0.6)
autoit.control_send(bot.title, '', '{F3}', 0)
bot.sleep(0.1,0.3)
autoit.control_send(bot.title, '', '{F1}', 0)
# bot.mouseRotate()
fullCounter = 0 |
<|file_name|>wl.py<|end_file_name|><|fim▁begin|>import pyautogui, win32api, win32con, ctypes, autoit
from PIL import ImageOps, Image, ImageGrab
from numpy import *
import os
import time
import cv2
import random
from Bot import *
def main():
bot = Bot()
autoit.win_wait(bot.title, 5)
counter = 0
poitonUse = 0
cycle = True
fullCounter = 0
while cycle:
hpstatus = bot.checkOwnHp()
print 'hp ' + str(hpstatus)
if hpstatus == 0:
autoit.control_send(bot.title, '', '{F9}', 0)
bot.sleep(0.3,0.6)
print 'Dead'
cv2.imwrite('Dead' + str(int(time.time())) + '.png',bot.getScreen(leftCornerx,leftCornery,x2,fullY2))
cycle = False
if hpstatus == 1:
if poitonUse == 0:
autoit.control_send(bot.title, '', '{F10}', 0)
poitonUse += 1
if poitonUse > 5:
poitonUse = 0
else:
poitonUse = 0
res = bot.findHP();
print 'tgs ' + str(res)
if res == 3:
fullCounter += 1
print 'fc ' + str(fullCounter)
autoit.control_send(bot.title, '', '{F1}', 0)
else:
fullCounter = 0
if fullCounter > 4:
autoit.control_send(bot.title, '', '{ESC}', 0)
bot.sleep(0.3,0.6)
autoit.control_send(bot.title, '', '{F3}', 0)
bot.sleep(0.1,0.3)
autoit.control_send(bot.title, '', '{F1}', 0)
# bot.mouseRotate()
fullCounter = 0
if res > 0:
<|fim_middle|>
else:
fullCounter = 0
if counter < 3:
autoit.control_send(bot.title, '', '{F3}', 0)
bot.sleep(0.5,0.8)
autoit.control_send(bot.title, '', '{F1}', 0)
print 'F3'
if counter > 2:
# bot.findTarget()
autoit.control_send(bot.title, '', '{F7}', 0)
# if counter > 3:
# autoit.control_send(bot.title, '', '{F8}', 0)
# counter = 0
counter += 1
print 'cnt ' + str(counter)
pass
if __name__ == '__main__':
main()
<|fim▁end|> | autoit.control_send(bot.title, '', '{F1}', 0)
counter = 0
if res == 1 or res == 3:
bot.sleep(0.3,0.6)
if res > 1 and res < 3:
bot.sleep(1,3)
if res == 1:
autoit.control_send(bot.title, '', '{F3}', 0)
bot.sleep(0.3,0.6)
autoit.control_send(bot.title, '', '{F2}', 0)
bot.sleep(0.3,0.6)
autoit.control_send(bot.title, '', '{F1}', 0) |
<|file_name|>wl.py<|end_file_name|><|fim▁begin|>import pyautogui, win32api, win32con, ctypes, autoit
from PIL import ImageOps, Image, ImageGrab
from numpy import *
import os
import time
import cv2
import random
from Bot import *
def main():
bot = Bot()
autoit.win_wait(bot.title, 5)
counter = 0
poitonUse = 0
cycle = True
fullCounter = 0
while cycle:
hpstatus = bot.checkOwnHp()
print 'hp ' + str(hpstatus)
if hpstatus == 0:
autoit.control_send(bot.title, '', '{F9}', 0)
bot.sleep(0.3,0.6)
print 'Dead'
cv2.imwrite('Dead' + str(int(time.time())) + '.png',bot.getScreen(leftCornerx,leftCornery,x2,fullY2))
cycle = False
if hpstatus == 1:
if poitonUse == 0:
autoit.control_send(bot.title, '', '{F10}', 0)
poitonUse += 1
if poitonUse > 5:
poitonUse = 0
else:
poitonUse = 0
res = bot.findHP();
print 'tgs ' + str(res)
if res == 3:
fullCounter += 1
print 'fc ' + str(fullCounter)
autoit.control_send(bot.title, '', '{F1}', 0)
else:
fullCounter = 0
if fullCounter > 4:
autoit.control_send(bot.title, '', '{ESC}', 0)
bot.sleep(0.3,0.6)
autoit.control_send(bot.title, '', '{F3}', 0)
bot.sleep(0.1,0.3)
autoit.control_send(bot.title, '', '{F1}', 0)
# bot.mouseRotate()
fullCounter = 0
if res > 0:
autoit.control_send(bot.title, '', '{F1}', 0)
counter = 0
if res == 1 or res == 3:
<|fim_middle|>
if res > 1 and res < 3:
bot.sleep(1,3)
if res == 1:
autoit.control_send(bot.title, '', '{F3}', 0)
bot.sleep(0.3,0.6)
autoit.control_send(bot.title, '', '{F2}', 0)
bot.sleep(0.3,0.6)
autoit.control_send(bot.title, '', '{F1}', 0)
else:
fullCounter = 0
if counter < 3:
autoit.control_send(bot.title, '', '{F3}', 0)
bot.sleep(0.5,0.8)
autoit.control_send(bot.title, '', '{F1}', 0)
print 'F3'
if counter > 2:
# bot.findTarget()
autoit.control_send(bot.title, '', '{F7}', 0)
# if counter > 3:
# autoit.control_send(bot.title, '', '{F8}', 0)
# counter = 0
counter += 1
print 'cnt ' + str(counter)
pass
if __name__ == '__main__':
main()
<|fim▁end|> | bot.sleep(0.3,0.6) |
<|file_name|>wl.py<|end_file_name|><|fim▁begin|>import pyautogui, win32api, win32con, ctypes, autoit
from PIL import ImageOps, Image, ImageGrab
from numpy import *
import os
import time
import cv2
import random
from Bot import *
def main():
bot = Bot()
autoit.win_wait(bot.title, 5)
counter = 0
poitonUse = 0
cycle = True
fullCounter = 0
while cycle:
hpstatus = bot.checkOwnHp()
print 'hp ' + str(hpstatus)
if hpstatus == 0:
autoit.control_send(bot.title, '', '{F9}', 0)
bot.sleep(0.3,0.6)
print 'Dead'
cv2.imwrite('Dead' + str(int(time.time())) + '.png',bot.getScreen(leftCornerx,leftCornery,x2,fullY2))
cycle = False
if hpstatus == 1:
if poitonUse == 0:
autoit.control_send(bot.title, '', '{F10}', 0)
poitonUse += 1
if poitonUse > 5:
poitonUse = 0
else:
poitonUse = 0
res = bot.findHP();
print 'tgs ' + str(res)
if res == 3:
fullCounter += 1
print 'fc ' + str(fullCounter)
autoit.control_send(bot.title, '', '{F1}', 0)
else:
fullCounter = 0
if fullCounter > 4:
autoit.control_send(bot.title, '', '{ESC}', 0)
bot.sleep(0.3,0.6)
autoit.control_send(bot.title, '', '{F3}', 0)
bot.sleep(0.1,0.3)
autoit.control_send(bot.title, '', '{F1}', 0)
# bot.mouseRotate()
fullCounter = 0
if res > 0:
autoit.control_send(bot.title, '', '{F1}', 0)
counter = 0
if res == 1 or res == 3:
bot.sleep(0.3,0.6)
if res > 1 and res < 3:
<|fim_middle|>
if res == 1:
autoit.control_send(bot.title, '', '{F3}', 0)
bot.sleep(0.3,0.6)
autoit.control_send(bot.title, '', '{F2}', 0)
bot.sleep(0.3,0.6)
autoit.control_send(bot.title, '', '{F1}', 0)
else:
fullCounter = 0
if counter < 3:
autoit.control_send(bot.title, '', '{F3}', 0)
bot.sleep(0.5,0.8)
autoit.control_send(bot.title, '', '{F1}', 0)
print 'F3'
if counter > 2:
# bot.findTarget()
autoit.control_send(bot.title, '', '{F7}', 0)
# if counter > 3:
# autoit.control_send(bot.title, '', '{F8}', 0)
# counter = 0
counter += 1
print 'cnt ' + str(counter)
pass
if __name__ == '__main__':
main()
<|fim▁end|> | bot.sleep(1,3) |
<|file_name|>wl.py<|end_file_name|><|fim▁begin|>import pyautogui, win32api, win32con, ctypes, autoit
from PIL import ImageOps, Image, ImageGrab
from numpy import *
import os
import time
import cv2
import random
from Bot import *
def main():
bot = Bot()
autoit.win_wait(bot.title, 5)
counter = 0
poitonUse = 0
cycle = True
fullCounter = 0
while cycle:
hpstatus = bot.checkOwnHp()
print 'hp ' + str(hpstatus)
if hpstatus == 0:
autoit.control_send(bot.title, '', '{F9}', 0)
bot.sleep(0.3,0.6)
print 'Dead'
cv2.imwrite('Dead' + str(int(time.time())) + '.png',bot.getScreen(leftCornerx,leftCornery,x2,fullY2))
cycle = False
if hpstatus == 1:
if poitonUse == 0:
autoit.control_send(bot.title, '', '{F10}', 0)
poitonUse += 1
if poitonUse > 5:
poitonUse = 0
else:
poitonUse = 0
res = bot.findHP();
print 'tgs ' + str(res)
if res == 3:
fullCounter += 1
print 'fc ' + str(fullCounter)
autoit.control_send(bot.title, '', '{F1}', 0)
else:
fullCounter = 0
if fullCounter > 4:
autoit.control_send(bot.title, '', '{ESC}', 0)
bot.sleep(0.3,0.6)
autoit.control_send(bot.title, '', '{F3}', 0)
bot.sleep(0.1,0.3)
autoit.control_send(bot.title, '', '{F1}', 0)
# bot.mouseRotate()
fullCounter = 0
if res > 0:
autoit.control_send(bot.title, '', '{F1}', 0)
counter = 0
if res == 1 or res == 3:
bot.sleep(0.3,0.6)
if res > 1 and res < 3:
bot.sleep(1,3)
if res == 1:
<|fim_middle|>
else:
fullCounter = 0
if counter < 3:
autoit.control_send(bot.title, '', '{F3}', 0)
bot.sleep(0.5,0.8)
autoit.control_send(bot.title, '', '{F1}', 0)
print 'F3'
if counter > 2:
# bot.findTarget()
autoit.control_send(bot.title, '', '{F7}', 0)
# if counter > 3:
# autoit.control_send(bot.title, '', '{F8}', 0)
# counter = 0
counter += 1
print 'cnt ' + str(counter)
pass
if __name__ == '__main__':
main()
<|fim▁end|> | autoit.control_send(bot.title, '', '{F3}', 0)
bot.sleep(0.3,0.6)
autoit.control_send(bot.title, '', '{F2}', 0)
bot.sleep(0.3,0.6)
autoit.control_send(bot.title, '', '{F1}', 0) |
<|file_name|>wl.py<|end_file_name|><|fim▁begin|>import pyautogui, win32api, win32con, ctypes, autoit
from PIL import ImageOps, Image, ImageGrab
from numpy import *
import os
import time
import cv2
import random
from Bot import *
def main():
bot = Bot()
autoit.win_wait(bot.title, 5)
counter = 0
poitonUse = 0
cycle = True
fullCounter = 0
while cycle:
hpstatus = bot.checkOwnHp()
print 'hp ' + str(hpstatus)
if hpstatus == 0:
autoit.control_send(bot.title, '', '{F9}', 0)
bot.sleep(0.3,0.6)
print 'Dead'
cv2.imwrite('Dead' + str(int(time.time())) + '.png',bot.getScreen(leftCornerx,leftCornery,x2,fullY2))
cycle = False
if hpstatus == 1:
if poitonUse == 0:
autoit.control_send(bot.title, '', '{F10}', 0)
poitonUse += 1
if poitonUse > 5:
poitonUse = 0
else:
poitonUse = 0
res = bot.findHP();
print 'tgs ' + str(res)
if res == 3:
fullCounter += 1
print 'fc ' + str(fullCounter)
autoit.control_send(bot.title, '', '{F1}', 0)
else:
fullCounter = 0
if fullCounter > 4:
autoit.control_send(bot.title, '', '{ESC}', 0)
bot.sleep(0.3,0.6)
autoit.control_send(bot.title, '', '{F3}', 0)
bot.sleep(0.1,0.3)
autoit.control_send(bot.title, '', '{F1}', 0)
# bot.mouseRotate()
fullCounter = 0
if res > 0:
autoit.control_send(bot.title, '', '{F1}', 0)
counter = 0
if res == 1 or res == 3:
bot.sleep(0.3,0.6)
if res > 1 and res < 3:
bot.sleep(1,3)
if res == 1:
autoit.control_send(bot.title, '', '{F3}', 0)
bot.sleep(0.3,0.6)
autoit.control_send(bot.title, '', '{F2}', 0)
bot.sleep(0.3,0.6)
autoit.control_send(bot.title, '', '{F1}', 0)
else:
<|fim_middle|>
print 'cnt ' + str(counter)
pass
if __name__ == '__main__':
main()
<|fim▁end|> | fullCounter = 0
if counter < 3:
autoit.control_send(bot.title, '', '{F3}', 0)
bot.sleep(0.5,0.8)
autoit.control_send(bot.title, '', '{F1}', 0)
print 'F3'
if counter > 2:
# bot.findTarget()
autoit.control_send(bot.title, '', '{F7}', 0)
# if counter > 3:
# autoit.control_send(bot.title, '', '{F8}', 0)
# counter = 0
counter += 1 |
<|file_name|>wl.py<|end_file_name|><|fim▁begin|>import pyautogui, win32api, win32con, ctypes, autoit
from PIL import ImageOps, Image, ImageGrab
from numpy import *
import os
import time
import cv2
import random
from Bot import *
def main():
bot = Bot()
autoit.win_wait(bot.title, 5)
counter = 0
poitonUse = 0
cycle = True
fullCounter = 0
while cycle:
hpstatus = bot.checkOwnHp()
print 'hp ' + str(hpstatus)
if hpstatus == 0:
autoit.control_send(bot.title, '', '{F9}', 0)
bot.sleep(0.3,0.6)
print 'Dead'
cv2.imwrite('Dead' + str(int(time.time())) + '.png',bot.getScreen(leftCornerx,leftCornery,x2,fullY2))
cycle = False
if hpstatus == 1:
if poitonUse == 0:
autoit.control_send(bot.title, '', '{F10}', 0)
poitonUse += 1
if poitonUse > 5:
poitonUse = 0
else:
poitonUse = 0
res = bot.findHP();
print 'tgs ' + str(res)
if res == 3:
fullCounter += 1
print 'fc ' + str(fullCounter)
autoit.control_send(bot.title, '', '{F1}', 0)
else:
fullCounter = 0
if fullCounter > 4:
autoit.control_send(bot.title, '', '{ESC}', 0)
bot.sleep(0.3,0.6)
autoit.control_send(bot.title, '', '{F3}', 0)
bot.sleep(0.1,0.3)
autoit.control_send(bot.title, '', '{F1}', 0)
# bot.mouseRotate()
fullCounter = 0
if res > 0:
autoit.control_send(bot.title, '', '{F1}', 0)
counter = 0
if res == 1 or res == 3:
bot.sleep(0.3,0.6)
if res > 1 and res < 3:
bot.sleep(1,3)
if res == 1:
autoit.control_send(bot.title, '', '{F3}', 0)
bot.sleep(0.3,0.6)
autoit.control_send(bot.title, '', '{F2}', 0)
bot.sleep(0.3,0.6)
autoit.control_send(bot.title, '', '{F1}', 0)
else:
fullCounter = 0
if counter < 3:
<|fim_middle|>
if counter > 2:
# bot.findTarget()
autoit.control_send(bot.title, '', '{F7}', 0)
# if counter > 3:
# autoit.control_send(bot.title, '', '{F8}', 0)
# counter = 0
counter += 1
print 'cnt ' + str(counter)
pass
if __name__ == '__main__':
main()
<|fim▁end|> | autoit.control_send(bot.title, '', '{F3}', 0)
bot.sleep(0.5,0.8)
autoit.control_send(bot.title, '', '{F1}', 0)
print 'F3' |
<|file_name|>wl.py<|end_file_name|><|fim▁begin|>import pyautogui, win32api, win32con, ctypes, autoit
from PIL import ImageOps, Image, ImageGrab
from numpy import *
import os
import time
import cv2
import random
from Bot import *
def main():
bot = Bot()
autoit.win_wait(bot.title, 5)
counter = 0
poitonUse = 0
cycle = True
fullCounter = 0
while cycle:
hpstatus = bot.checkOwnHp()
print 'hp ' + str(hpstatus)
if hpstatus == 0:
autoit.control_send(bot.title, '', '{F9}', 0)
bot.sleep(0.3,0.6)
print 'Dead'
cv2.imwrite('Dead' + str(int(time.time())) + '.png',bot.getScreen(leftCornerx,leftCornery,x2,fullY2))
cycle = False
if hpstatus == 1:
if poitonUse == 0:
autoit.control_send(bot.title, '', '{F10}', 0)
poitonUse += 1
if poitonUse > 5:
poitonUse = 0
else:
poitonUse = 0
res = bot.findHP();
print 'tgs ' + str(res)
if res == 3:
fullCounter += 1
print 'fc ' + str(fullCounter)
autoit.control_send(bot.title, '', '{F1}', 0)
else:
fullCounter = 0
if fullCounter > 4:
autoit.control_send(bot.title, '', '{ESC}', 0)
bot.sleep(0.3,0.6)
autoit.control_send(bot.title, '', '{F3}', 0)
bot.sleep(0.1,0.3)
autoit.control_send(bot.title, '', '{F1}', 0)
# bot.mouseRotate()
fullCounter = 0
if res > 0:
autoit.control_send(bot.title, '', '{F1}', 0)
counter = 0
if res == 1 or res == 3:
bot.sleep(0.3,0.6)
if res > 1 and res < 3:
bot.sleep(1,3)
if res == 1:
autoit.control_send(bot.title, '', '{F3}', 0)
bot.sleep(0.3,0.6)
autoit.control_send(bot.title, '', '{F2}', 0)
bot.sleep(0.3,0.6)
autoit.control_send(bot.title, '', '{F1}', 0)
else:
fullCounter = 0
if counter < 3:
autoit.control_send(bot.title, '', '{F3}', 0)
bot.sleep(0.5,0.8)
autoit.control_send(bot.title, '', '{F1}', 0)
print 'F3'
if counter > 2:
# bot.findTarget()
<|fim_middle|>
# if counter > 3:
# autoit.control_send(bot.title, '', '{F8}', 0)
# counter = 0
counter += 1
print 'cnt ' + str(counter)
pass
if __name__ == '__main__':
main()
<|fim▁end|> | autoit.control_send(bot.title, '', '{F7}', 0) |
<|file_name|>wl.py<|end_file_name|><|fim▁begin|>import pyautogui, win32api, win32con, ctypes, autoit
from PIL import ImageOps, Image, ImageGrab
from numpy import *
import os
import time
import cv2
import random
from Bot import *
def main():
bot = Bot()
autoit.win_wait(bot.title, 5)
counter = 0
poitonUse = 0
cycle = True
fullCounter = 0
while cycle:
hpstatus = bot.checkOwnHp()
print 'hp ' + str(hpstatus)
if hpstatus == 0:
autoit.control_send(bot.title, '', '{F9}', 0)
bot.sleep(0.3,0.6)
print 'Dead'
cv2.imwrite('Dead' + str(int(time.time())) + '.png',bot.getScreen(leftCornerx,leftCornery,x2,fullY2))
cycle = False
if hpstatus == 1:
if poitonUse == 0:
autoit.control_send(bot.title, '', '{F10}', 0)
poitonUse += 1
if poitonUse > 5:
poitonUse = 0
else:
poitonUse = 0
res = bot.findHP();
print 'tgs ' + str(res)
if res == 3:
fullCounter += 1
print 'fc ' + str(fullCounter)
autoit.control_send(bot.title, '', '{F1}', 0)
else:
fullCounter = 0
if fullCounter > 4:
autoit.control_send(bot.title, '', '{ESC}', 0)
bot.sleep(0.3,0.6)
autoit.control_send(bot.title, '', '{F3}', 0)
bot.sleep(0.1,0.3)
autoit.control_send(bot.title, '', '{F1}', 0)
# bot.mouseRotate()
fullCounter = 0
if res > 0:
autoit.control_send(bot.title, '', '{F1}', 0)
counter = 0
if res == 1 or res == 3:
bot.sleep(0.3,0.6)
if res > 1 and res < 3:
bot.sleep(1,3)
if res == 1:
autoit.control_send(bot.title, '', '{F3}', 0)
bot.sleep(0.3,0.6)
autoit.control_send(bot.title, '', '{F2}', 0)
bot.sleep(0.3,0.6)
autoit.control_send(bot.title, '', '{F1}', 0)
else:
fullCounter = 0
if counter < 3:
autoit.control_send(bot.title, '', '{F3}', 0)
bot.sleep(0.5,0.8)
autoit.control_send(bot.title, '', '{F1}', 0)
print 'F3'
if counter > 2:
# bot.findTarget()
autoit.control_send(bot.title, '', '{F7}', 0)
# if counter > 3:
# autoit.control_send(bot.title, '', '{F8}', 0)
# counter = 0
counter += 1
print 'cnt ' + str(counter)
pass
if __name__ == '__main__':
<|fim_middle|>
<|fim▁end|> | main() |
<|file_name|>wl.py<|end_file_name|><|fim▁begin|>import pyautogui, win32api, win32con, ctypes, autoit
from PIL import ImageOps, Image, ImageGrab
from numpy import *
import os
import time
import cv2
import random
from Bot import *
def <|fim_middle|>():
bot = Bot()
autoit.win_wait(bot.title, 5)
counter = 0
poitonUse = 0
cycle = True
fullCounter = 0
while cycle:
hpstatus = bot.checkOwnHp()
print 'hp ' + str(hpstatus)
if hpstatus == 0:
autoit.control_send(bot.title, '', '{F9}', 0)
bot.sleep(0.3,0.6)
print 'Dead'
cv2.imwrite('Dead' + str(int(time.time())) + '.png',bot.getScreen(leftCornerx,leftCornery,x2,fullY2))
cycle = False
if hpstatus == 1:
if poitonUse == 0:
autoit.control_send(bot.title, '', '{F10}', 0)
poitonUse += 1
if poitonUse > 5:
poitonUse = 0
else:
poitonUse = 0
res = bot.findHP();
print 'tgs ' + str(res)
if res == 3:
fullCounter += 1
print 'fc ' + str(fullCounter)
autoit.control_send(bot.title, '', '{F1}', 0)
else:
fullCounter = 0
if fullCounter > 4:
autoit.control_send(bot.title, '', '{ESC}', 0)
bot.sleep(0.3,0.6)
autoit.control_send(bot.title, '', '{F3}', 0)
bot.sleep(0.1,0.3)
autoit.control_send(bot.title, '', '{F1}', 0)
# bot.mouseRotate()
fullCounter = 0
if res > 0:
autoit.control_send(bot.title, '', '{F1}', 0)
counter = 0
if res == 1 or res == 3:
bot.sleep(0.3,0.6)
if res > 1 and res < 3:
bot.sleep(1,3)
if res == 1:
autoit.control_send(bot.title, '', '{F3}', 0)
bot.sleep(0.3,0.6)
autoit.control_send(bot.title, '', '{F2}', 0)
bot.sleep(0.3,0.6)
autoit.control_send(bot.title, '', '{F1}', 0)
else:
fullCounter = 0
if counter < 3:
autoit.control_send(bot.title, '', '{F3}', 0)
bot.sleep(0.5,0.8)
autoit.control_send(bot.title, '', '{F1}', 0)
print 'F3'
if counter > 2:
# bot.findTarget()
autoit.control_send(bot.title, '', '{F7}', 0)
# if counter > 3:
# autoit.control_send(bot.title, '', '{F8}', 0)
# counter = 0
counter += 1
print 'cnt ' + str(counter)
pass
if __name__ == '__main__':
main()
<|fim▁end|> | main |
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|><|fim▁hole|> print('Docker Service Module')
if __name__ == '__main__':
main()<|fim▁end|> | def main():
"""Instantiate a DockerStats object and collect stats.""" |
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|>def main():
<|fim_middle|>
if __name__ == '__main__':
main()
<|fim▁end|> | """Instantiate a DockerStats object and collect stats."""
print('Docker Service Module') |
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|>def main():
"""Instantiate a DockerStats object and collect stats."""
print('Docker Service Module')
if __name__ == '__main__':
<|fim_middle|>
<|fim▁end|> | main() |
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|>def <|fim_middle|>():
"""Instantiate a DockerStats object and collect stats."""
print('Docker Service Module')
if __name__ == '__main__':
main()
<|fim▁end|> | main |
<|file_name|>frontend-results.py<|end_file_name|><|fim▁begin|>@app.route('/job/<name>')
def results(name):
job = saliweb.frontend.get_completed_job(name,
flask.request.args.get('passwd'))
# Determine whether the job completed successfully<|fim▁hole|> template = 'results_ok.html'
else:
template = 'results_failed.html'
return saliweb.frontend.render_results_template(template, job=job)<|fim▁end|> | if os.path.exists(job.get_path('output.pdb')): |
<|file_name|>frontend-results.py<|end_file_name|><|fim▁begin|>@app.route('/job/<name>')
def results(name):
<|fim_middle|>
<|fim▁end|> | job = saliweb.frontend.get_completed_job(name,
flask.request.args.get('passwd'))
# Determine whether the job completed successfully
if os.path.exists(job.get_path('output.pdb')):
template = 'results_ok.html'
else:
template = 'results_failed.html'
return saliweb.frontend.render_results_template(template, job=job) |
<|file_name|>frontend-results.py<|end_file_name|><|fim▁begin|>@app.route('/job/<name>')
def results(name):
job = saliweb.frontend.get_completed_job(name,
flask.request.args.get('passwd'))
# Determine whether the job completed successfully
if os.path.exists(job.get_path('output.pdb')):
<|fim_middle|>
else:
template = 'results_failed.html'
return saliweb.frontend.render_results_template(template, job=job)
<|fim▁end|> | template = 'results_ok.html' |
<|file_name|>frontend-results.py<|end_file_name|><|fim▁begin|>@app.route('/job/<name>')
def results(name):
job = saliweb.frontend.get_completed_job(name,
flask.request.args.get('passwd'))
# Determine whether the job completed successfully
if os.path.exists(job.get_path('output.pdb')):
template = 'results_ok.html'
else:
<|fim_middle|>
return saliweb.frontend.render_results_template(template, job=job)
<|fim▁end|> | template = 'results_failed.html' |
<|file_name|>frontend-results.py<|end_file_name|><|fim▁begin|>@app.route('/job/<name>')
def <|fim_middle|>(name):
job = saliweb.frontend.get_completed_job(name,
flask.request.args.get('passwd'))
# Determine whether the job completed successfully
if os.path.exists(job.get_path('output.pdb')):
template = 'results_ok.html'
else:
template = 'results_failed.html'
return saliweb.frontend.render_results_template(template, job=job)
<|fim▁end|> | results |
<|file_name|>keys.py<|end_file_name|><|fim▁begin|>from __future__ import unicode_literals
__all__ = (
'Key',
'Keys',
)
class Key(object):
def __init__(self, name):
#: Descriptive way of writing keys in configuration files. e.g. <C-A>
#: for ``Control-A``.
self.name = name
def __repr__(self):
return '%s(%r)' % (self.__class__.__name__, self.name)
class Keys(object):
Escape = Key('<Escape>')
<|fim▁hole|> ControlC = Key('<C-C>')
ControlD = Key('<C-D>')
ControlE = Key('<C-E>')
ControlF = Key('<C-F>')
ControlG = Key('<C-G>')
ControlH = Key('<C-H>')
ControlI = Key('<C-I>') # Tab
ControlJ = Key('<C-J>') # Enter
ControlK = Key('<C-K>')
ControlL = Key('<C-L>')
ControlM = Key('<C-M>') # Enter
ControlN = Key('<C-N>')
ControlO = Key('<C-O>')
ControlP = Key('<C-P>')
ControlQ = Key('<C-Q>')
ControlR = Key('<C-R>')
ControlS = Key('<C-S>')
ControlT = Key('<C-T>')
ControlU = Key('<C-U>')
ControlV = Key('<C-V>')
ControlW = Key('<C-W>')
ControlX = Key('<C-X>')
ControlY = Key('<C-Y>')
ControlZ = Key('<C-Z>')
ControlSpace = Key('<C-Space>')
ControlBackslash = Key('<C-Backslash>')
ControlSquareClose = Key('<C-SquareClose>')
ControlCircumflex = Key('<C-Circumflex>')
ControlUnderscore = Key('<C-Underscore>')
ControlLeft = Key('<C-Left>')
ControlRight = Key('<C-Right>')
ControlUp = Key('<C-Up>')
ControlDown = Key('<C-Down>')
Up = Key('<Up>')
Down = Key('<Down>')
Right = Key('<Right>')
Left = Key('<Left>')
Home = Key('<Home>')
End = Key('<End>')
Delete = Key('<Delete>')
ShiftDelete = Key('<ShiftDelete>')
PageUp = Key('<PageUp>')
PageDown = Key('<PageDown>')
BackTab = Key('<BackTab>') # shift + tab
Tab = ControlI
Backspace = ControlH
F1 = Key('<F1>')
F2 = Key('<F2>')
F3 = Key('<F3>')
F4 = Key('<F4>')
F5 = Key('<F5>')
F6 = Key('<F6>')
F7 = Key('<F7>')
F8 = Key('<F8>')
F9 = Key('<F9>')
F10 = Key('<F10>')
F11 = Key('<F11>')
F12 = Key('<F12>')
F13 = Key('<F13>')
F14 = Key('<F14>')
F15 = Key('<F15>')
F16 = Key('<F16>')
F17 = Key('<F17>')
F18 = Key('<F18>')
F19 = Key('<F19>')
F20 = Key('<F20>')
# Matches any key.
Any = Key('<Any>')
# Special
CPRResponse = Key('<Cursor-Position-Response>')<|fim▁end|> | ControlA = Key('<C-A>')
ControlB = Key('<C-B>') |
<|file_name|>keys.py<|end_file_name|><|fim▁begin|>from __future__ import unicode_literals
__all__ = (
'Key',
'Keys',
)
class Key(object):
<|fim_middle|>
class Keys(object):
Escape = Key('<Escape>')
ControlA = Key('<C-A>')
ControlB = Key('<C-B>')
ControlC = Key('<C-C>')
ControlD = Key('<C-D>')
ControlE = Key('<C-E>')
ControlF = Key('<C-F>')
ControlG = Key('<C-G>')
ControlH = Key('<C-H>')
ControlI = Key('<C-I>') # Tab
ControlJ = Key('<C-J>') # Enter
ControlK = Key('<C-K>')
ControlL = Key('<C-L>')
ControlM = Key('<C-M>') # Enter
ControlN = Key('<C-N>')
ControlO = Key('<C-O>')
ControlP = Key('<C-P>')
ControlQ = Key('<C-Q>')
ControlR = Key('<C-R>')
ControlS = Key('<C-S>')
ControlT = Key('<C-T>')
ControlU = Key('<C-U>')
ControlV = Key('<C-V>')
ControlW = Key('<C-W>')
ControlX = Key('<C-X>')
ControlY = Key('<C-Y>')
ControlZ = Key('<C-Z>')
ControlSpace = Key('<C-Space>')
ControlBackslash = Key('<C-Backslash>')
ControlSquareClose = Key('<C-SquareClose>')
ControlCircumflex = Key('<C-Circumflex>')
ControlUnderscore = Key('<C-Underscore>')
ControlLeft = Key('<C-Left>')
ControlRight = Key('<C-Right>')
ControlUp = Key('<C-Up>')
ControlDown = Key('<C-Down>')
Up = Key('<Up>')
Down = Key('<Down>')
Right = Key('<Right>')
Left = Key('<Left>')
Home = Key('<Home>')
End = Key('<End>')
Delete = Key('<Delete>')
ShiftDelete = Key('<ShiftDelete>')
PageUp = Key('<PageUp>')
PageDown = Key('<PageDown>')
BackTab = Key('<BackTab>') # shift + tab
Tab = ControlI
Backspace = ControlH
F1 = Key('<F1>')
F2 = Key('<F2>')
F3 = Key('<F3>')
F4 = Key('<F4>')
F5 = Key('<F5>')
F6 = Key('<F6>')
F7 = Key('<F7>')
F8 = Key('<F8>')
F9 = Key('<F9>')
F10 = Key('<F10>')
F11 = Key('<F11>')
F12 = Key('<F12>')
F13 = Key('<F13>')
F14 = Key('<F14>')
F15 = Key('<F15>')
F16 = Key('<F16>')
F17 = Key('<F17>')
F18 = Key('<F18>')
F19 = Key('<F19>')
F20 = Key('<F20>')
# Matches any key.
Any = Key('<Any>')
# Special
CPRResponse = Key('<Cursor-Position-Response>')
<|fim▁end|> | def __init__(self, name):
#: Descriptive way of writing keys in configuration files. e.g. <C-A>
#: for ``Control-A``.
self.name = name
def __repr__(self):
return '%s(%r)' % (self.__class__.__name__, self.name) |
<|file_name|>keys.py<|end_file_name|><|fim▁begin|>from __future__ import unicode_literals
__all__ = (
'Key',
'Keys',
)
class Key(object):
def __init__(self, name):
#: Descriptive way of writing keys in configuration files. e.g. <C-A>
#: for ``Control-A``.
<|fim_middle|>
def __repr__(self):
return '%s(%r)' % (self.__class__.__name__, self.name)
class Keys(object):
Escape = Key('<Escape>')
ControlA = Key('<C-A>')
ControlB = Key('<C-B>')
ControlC = Key('<C-C>')
ControlD = Key('<C-D>')
ControlE = Key('<C-E>')
ControlF = Key('<C-F>')
ControlG = Key('<C-G>')
ControlH = Key('<C-H>')
ControlI = Key('<C-I>') # Tab
ControlJ = Key('<C-J>') # Enter
ControlK = Key('<C-K>')
ControlL = Key('<C-L>')
ControlM = Key('<C-M>') # Enter
ControlN = Key('<C-N>')
ControlO = Key('<C-O>')
ControlP = Key('<C-P>')
ControlQ = Key('<C-Q>')
ControlR = Key('<C-R>')
ControlS = Key('<C-S>')
ControlT = Key('<C-T>')
ControlU = Key('<C-U>')
ControlV = Key('<C-V>')
ControlW = Key('<C-W>')
ControlX = Key('<C-X>')
ControlY = Key('<C-Y>')
ControlZ = Key('<C-Z>')
ControlSpace = Key('<C-Space>')
ControlBackslash = Key('<C-Backslash>')
ControlSquareClose = Key('<C-SquareClose>')
ControlCircumflex = Key('<C-Circumflex>')
ControlUnderscore = Key('<C-Underscore>')
ControlLeft = Key('<C-Left>')
ControlRight = Key('<C-Right>')
ControlUp = Key('<C-Up>')
ControlDown = Key('<C-Down>')
Up = Key('<Up>')
Down = Key('<Down>')
Right = Key('<Right>')
Left = Key('<Left>')
Home = Key('<Home>')
End = Key('<End>')
Delete = Key('<Delete>')
ShiftDelete = Key('<ShiftDelete>')
PageUp = Key('<PageUp>')
PageDown = Key('<PageDown>')
BackTab = Key('<BackTab>') # shift + tab
Tab = ControlI
Backspace = ControlH
F1 = Key('<F1>')
F2 = Key('<F2>')
F3 = Key('<F3>')
F4 = Key('<F4>')
F5 = Key('<F5>')
F6 = Key('<F6>')
F7 = Key('<F7>')
F8 = Key('<F8>')
F9 = Key('<F9>')
F10 = Key('<F10>')
F11 = Key('<F11>')
F12 = Key('<F12>')
F13 = Key('<F13>')
F14 = Key('<F14>')
F15 = Key('<F15>')
F16 = Key('<F16>')
F17 = Key('<F17>')
F18 = Key('<F18>')
F19 = Key('<F19>')
F20 = Key('<F20>')
# Matches any key.
Any = Key('<Any>')
# Special
CPRResponse = Key('<Cursor-Position-Response>')
<|fim▁end|> | self.name = name |
<|file_name|>keys.py<|end_file_name|><|fim▁begin|>from __future__ import unicode_literals
__all__ = (
'Key',
'Keys',
)
class Key(object):
def __init__(self, name):
#: Descriptive way of writing keys in configuration files. e.g. <C-A>
#: for ``Control-A``.
self.name = name
def __repr__(self):
<|fim_middle|>
class Keys(object):
Escape = Key('<Escape>')
ControlA = Key('<C-A>')
ControlB = Key('<C-B>')
ControlC = Key('<C-C>')
ControlD = Key('<C-D>')
ControlE = Key('<C-E>')
ControlF = Key('<C-F>')
ControlG = Key('<C-G>')
ControlH = Key('<C-H>')
ControlI = Key('<C-I>') # Tab
ControlJ = Key('<C-J>') # Enter
ControlK = Key('<C-K>')
ControlL = Key('<C-L>')
ControlM = Key('<C-M>') # Enter
ControlN = Key('<C-N>')
ControlO = Key('<C-O>')
ControlP = Key('<C-P>')
ControlQ = Key('<C-Q>')
ControlR = Key('<C-R>')
ControlS = Key('<C-S>')
ControlT = Key('<C-T>')
ControlU = Key('<C-U>')
ControlV = Key('<C-V>')
ControlW = Key('<C-W>')
ControlX = Key('<C-X>')
ControlY = Key('<C-Y>')
ControlZ = Key('<C-Z>')
ControlSpace = Key('<C-Space>')
ControlBackslash = Key('<C-Backslash>')
ControlSquareClose = Key('<C-SquareClose>')
ControlCircumflex = Key('<C-Circumflex>')
ControlUnderscore = Key('<C-Underscore>')
ControlLeft = Key('<C-Left>')
ControlRight = Key('<C-Right>')
ControlUp = Key('<C-Up>')
ControlDown = Key('<C-Down>')
Up = Key('<Up>')
Down = Key('<Down>')
Right = Key('<Right>')
Left = Key('<Left>')
Home = Key('<Home>')
End = Key('<End>')
Delete = Key('<Delete>')
ShiftDelete = Key('<ShiftDelete>')
PageUp = Key('<PageUp>')
PageDown = Key('<PageDown>')
BackTab = Key('<BackTab>') # shift + tab
Tab = ControlI
Backspace = ControlH
F1 = Key('<F1>')
F2 = Key('<F2>')
F3 = Key('<F3>')
F4 = Key('<F4>')
F5 = Key('<F5>')
F6 = Key('<F6>')
F7 = Key('<F7>')
F8 = Key('<F8>')
F9 = Key('<F9>')
F10 = Key('<F10>')
F11 = Key('<F11>')
F12 = Key('<F12>')
F13 = Key('<F13>')
F14 = Key('<F14>')
F15 = Key('<F15>')
F16 = Key('<F16>')
F17 = Key('<F17>')
F18 = Key('<F18>')
F19 = Key('<F19>')
F20 = Key('<F20>')
# Matches any key.
Any = Key('<Any>')
# Special
CPRResponse = Key('<Cursor-Position-Response>')
<|fim▁end|> | return '%s(%r)' % (self.__class__.__name__, self.name) |
<|file_name|>keys.py<|end_file_name|><|fim▁begin|>from __future__ import unicode_literals
__all__ = (
'Key',
'Keys',
)
class Key(object):
def __init__(self, name):
#: Descriptive way of writing keys in configuration files. e.g. <C-A>
#: for ``Control-A``.
self.name = name
def __repr__(self):
return '%s(%r)' % (self.__class__.__name__, self.name)
class Keys(object):
<|fim_middle|>
<|fim▁end|> | Escape = Key('<Escape>')
ControlA = Key('<C-A>')
ControlB = Key('<C-B>')
ControlC = Key('<C-C>')
ControlD = Key('<C-D>')
ControlE = Key('<C-E>')
ControlF = Key('<C-F>')
ControlG = Key('<C-G>')
ControlH = Key('<C-H>')
ControlI = Key('<C-I>') # Tab
ControlJ = Key('<C-J>') # Enter
ControlK = Key('<C-K>')
ControlL = Key('<C-L>')
ControlM = Key('<C-M>') # Enter
ControlN = Key('<C-N>')
ControlO = Key('<C-O>')
ControlP = Key('<C-P>')
ControlQ = Key('<C-Q>')
ControlR = Key('<C-R>')
ControlS = Key('<C-S>')
ControlT = Key('<C-T>')
ControlU = Key('<C-U>')
ControlV = Key('<C-V>')
ControlW = Key('<C-W>')
ControlX = Key('<C-X>')
ControlY = Key('<C-Y>')
ControlZ = Key('<C-Z>')
ControlSpace = Key('<C-Space>')
ControlBackslash = Key('<C-Backslash>')
ControlSquareClose = Key('<C-SquareClose>')
ControlCircumflex = Key('<C-Circumflex>')
ControlUnderscore = Key('<C-Underscore>')
ControlLeft = Key('<C-Left>')
ControlRight = Key('<C-Right>')
ControlUp = Key('<C-Up>')
ControlDown = Key('<C-Down>')
Up = Key('<Up>')
Down = Key('<Down>')
Right = Key('<Right>')
Left = Key('<Left>')
Home = Key('<Home>')
End = Key('<End>')
Delete = Key('<Delete>')
ShiftDelete = Key('<ShiftDelete>')
PageUp = Key('<PageUp>')
PageDown = Key('<PageDown>')
BackTab = Key('<BackTab>') # shift + tab
Tab = ControlI
Backspace = ControlH
F1 = Key('<F1>')
F2 = Key('<F2>')
F3 = Key('<F3>')
F4 = Key('<F4>')
F5 = Key('<F5>')
F6 = Key('<F6>')
F7 = Key('<F7>')
F8 = Key('<F8>')
F9 = Key('<F9>')
F10 = Key('<F10>')
F11 = Key('<F11>')
F12 = Key('<F12>')
F13 = Key('<F13>')
F14 = Key('<F14>')
F15 = Key('<F15>')
F16 = Key('<F16>')
F17 = Key('<F17>')
F18 = Key('<F18>')
F19 = Key('<F19>')
F20 = Key('<F20>')
# Matches any key.
Any = Key('<Any>')
# Special
CPRResponse = Key('<Cursor-Position-Response>') |
<|file_name|>keys.py<|end_file_name|><|fim▁begin|>from __future__ import unicode_literals
__all__ = (
'Key',
'Keys',
)
class Key(object):
def <|fim_middle|>(self, name):
#: Descriptive way of writing keys in configuration files. e.g. <C-A>
#: for ``Control-A``.
self.name = name
def __repr__(self):
return '%s(%r)' % (self.__class__.__name__, self.name)
class Keys(object):
Escape = Key('<Escape>')
ControlA = Key('<C-A>')
ControlB = Key('<C-B>')
ControlC = Key('<C-C>')
ControlD = Key('<C-D>')
ControlE = Key('<C-E>')
ControlF = Key('<C-F>')
ControlG = Key('<C-G>')
ControlH = Key('<C-H>')
ControlI = Key('<C-I>') # Tab
ControlJ = Key('<C-J>') # Enter
ControlK = Key('<C-K>')
ControlL = Key('<C-L>')
ControlM = Key('<C-M>') # Enter
ControlN = Key('<C-N>')
ControlO = Key('<C-O>')
ControlP = Key('<C-P>')
ControlQ = Key('<C-Q>')
ControlR = Key('<C-R>')
ControlS = Key('<C-S>')
ControlT = Key('<C-T>')
ControlU = Key('<C-U>')
ControlV = Key('<C-V>')
ControlW = Key('<C-W>')
ControlX = Key('<C-X>')
ControlY = Key('<C-Y>')
ControlZ = Key('<C-Z>')
ControlSpace = Key('<C-Space>')
ControlBackslash = Key('<C-Backslash>')
ControlSquareClose = Key('<C-SquareClose>')
ControlCircumflex = Key('<C-Circumflex>')
ControlUnderscore = Key('<C-Underscore>')
ControlLeft = Key('<C-Left>')
ControlRight = Key('<C-Right>')
ControlUp = Key('<C-Up>')
ControlDown = Key('<C-Down>')
Up = Key('<Up>')
Down = Key('<Down>')
Right = Key('<Right>')
Left = Key('<Left>')
Home = Key('<Home>')
End = Key('<End>')
Delete = Key('<Delete>')
ShiftDelete = Key('<ShiftDelete>')
PageUp = Key('<PageUp>')
PageDown = Key('<PageDown>')
BackTab = Key('<BackTab>') # shift + tab
Tab = ControlI
Backspace = ControlH
F1 = Key('<F1>')
F2 = Key('<F2>')
F3 = Key('<F3>')
F4 = Key('<F4>')
F5 = Key('<F5>')
F6 = Key('<F6>')
F7 = Key('<F7>')
F8 = Key('<F8>')
F9 = Key('<F9>')
F10 = Key('<F10>')
F11 = Key('<F11>')
F12 = Key('<F12>')
F13 = Key('<F13>')
F14 = Key('<F14>')
F15 = Key('<F15>')
F16 = Key('<F16>')
F17 = Key('<F17>')
F18 = Key('<F18>')
F19 = Key('<F19>')
F20 = Key('<F20>')
# Matches any key.
Any = Key('<Any>')
# Special
CPRResponse = Key('<Cursor-Position-Response>')
<|fim▁end|> | __init__ |
<|file_name|>keys.py<|end_file_name|><|fim▁begin|>from __future__ import unicode_literals
__all__ = (
'Key',
'Keys',
)
class Key(object):
def __init__(self, name):
#: Descriptive way of writing keys in configuration files. e.g. <C-A>
#: for ``Control-A``.
self.name = name
def <|fim_middle|>(self):
return '%s(%r)' % (self.__class__.__name__, self.name)
class Keys(object):
Escape = Key('<Escape>')
ControlA = Key('<C-A>')
ControlB = Key('<C-B>')
ControlC = Key('<C-C>')
ControlD = Key('<C-D>')
ControlE = Key('<C-E>')
ControlF = Key('<C-F>')
ControlG = Key('<C-G>')
ControlH = Key('<C-H>')
ControlI = Key('<C-I>') # Tab
ControlJ = Key('<C-J>') # Enter
ControlK = Key('<C-K>')
ControlL = Key('<C-L>')
ControlM = Key('<C-M>') # Enter
ControlN = Key('<C-N>')
ControlO = Key('<C-O>')
ControlP = Key('<C-P>')
ControlQ = Key('<C-Q>')
ControlR = Key('<C-R>')
ControlS = Key('<C-S>')
ControlT = Key('<C-T>')
ControlU = Key('<C-U>')
ControlV = Key('<C-V>')
ControlW = Key('<C-W>')
ControlX = Key('<C-X>')
ControlY = Key('<C-Y>')
ControlZ = Key('<C-Z>')
ControlSpace = Key('<C-Space>')
ControlBackslash = Key('<C-Backslash>')
ControlSquareClose = Key('<C-SquareClose>')
ControlCircumflex = Key('<C-Circumflex>')
ControlUnderscore = Key('<C-Underscore>')
ControlLeft = Key('<C-Left>')
ControlRight = Key('<C-Right>')
ControlUp = Key('<C-Up>')
ControlDown = Key('<C-Down>')
Up = Key('<Up>')
Down = Key('<Down>')
Right = Key('<Right>')
Left = Key('<Left>')
Home = Key('<Home>')
End = Key('<End>')
Delete = Key('<Delete>')
ShiftDelete = Key('<ShiftDelete>')
PageUp = Key('<PageUp>')
PageDown = Key('<PageDown>')
BackTab = Key('<BackTab>') # shift + tab
Tab = ControlI
Backspace = ControlH
F1 = Key('<F1>')
F2 = Key('<F2>')
F3 = Key('<F3>')
F4 = Key('<F4>')
F5 = Key('<F5>')
F6 = Key('<F6>')
F7 = Key('<F7>')
F8 = Key('<F8>')
F9 = Key('<F9>')
F10 = Key('<F10>')
F11 = Key('<F11>')
F12 = Key('<F12>')
F13 = Key('<F13>')
F14 = Key('<F14>')
F15 = Key('<F15>')
F16 = Key('<F16>')
F17 = Key('<F17>')
F18 = Key('<F18>')
F19 = Key('<F19>')
F20 = Key('<F20>')
# Matches any key.
Any = Key('<Any>')
# Special
CPRResponse = Key('<Cursor-Position-Response>')
<|fim▁end|> | __repr__ |
<|file_name|>admin.py<|end_file_name|><|fim▁begin|>from django.contrib import admin
try:
from django.contrib.auth import get_permission_codename
except ImportError: # pragma: no cover
# Django < 1.6
def get_permission_codename(action, opts):
return '%s_%s' % (action, opts.object_name.lower())
<|fim▁hole|> codename = get_permission_codename('change', opts)
return request.user.has_perm('%s.%s' % (opts.app_label, codename), obj)
def has_delete_permission(self, request, obj=None):
opts = self.opts
codename = get_permission_codename('delete', opts)
return request.user.has_perm('%s.%s' % (opts.app_label, codename), obj)
class ObjectPermissionsInlineModelAdminMixin(ObjectPermissionsModelAdminMixin):
def has_change_permission(self, request, obj=None): # pragma: no cover
opts = self.opts
if opts.auto_created:
for field in opts.fields:
if field.rel and field.rel.to != self.parent_model:
opts = field.rel.to._meta
break
codename = get_permission_codename('change', opts)
return request.user.has_perm('%s.%s' % (opts.app_label, codename), obj)
def has_delete_permission(self, request, obj=None): # pragma: no cover
if self.opts.auto_created:
return self.has_change_permission(request, obj)
return super(ObjectPermissionsInlineModelAdminMixin, self).has_delete_permission(request, obj)
class ObjectPermissionsModelAdmin(ObjectPermissionsModelAdminMixin, admin.ModelAdmin):
pass
class ObjectPermissionsStackedInline(ObjectPermissionsInlineModelAdminMixin, admin.StackedInline):
pass
class ObjectPermissionsTabularInline(ObjectPermissionsInlineModelAdminMixin, admin.TabularInline):
pass<|fim▁end|> |
class ObjectPermissionsModelAdminMixin(object):
def has_change_permission(self, request, obj=None):
opts = self.opts |
<|file_name|>admin.py<|end_file_name|><|fim▁begin|>from django.contrib import admin
try:
from django.contrib.auth import get_permission_codename
except ImportError: # pragma: no cover
# Django < 1.6
def get_permission_codename(action, opts):
<|fim_middle|>
class ObjectPermissionsModelAdminMixin(object):
def has_change_permission(self, request, obj=None):
opts = self.opts
codename = get_permission_codename('change', opts)
return request.user.has_perm('%s.%s' % (opts.app_label, codename), obj)
def has_delete_permission(self, request, obj=None):
opts = self.opts
codename = get_permission_codename('delete', opts)
return request.user.has_perm('%s.%s' % (opts.app_label, codename), obj)
class ObjectPermissionsInlineModelAdminMixin(ObjectPermissionsModelAdminMixin):
def has_change_permission(self, request, obj=None): # pragma: no cover
opts = self.opts
if opts.auto_created:
for field in opts.fields:
if field.rel and field.rel.to != self.parent_model:
opts = field.rel.to._meta
break
codename = get_permission_codename('change', opts)
return request.user.has_perm('%s.%s' % (opts.app_label, codename), obj)
def has_delete_permission(self, request, obj=None): # pragma: no cover
if self.opts.auto_created:
return self.has_change_permission(request, obj)
return super(ObjectPermissionsInlineModelAdminMixin, self).has_delete_permission(request, obj)
class ObjectPermissionsModelAdmin(ObjectPermissionsModelAdminMixin, admin.ModelAdmin):
pass
class ObjectPermissionsStackedInline(ObjectPermissionsInlineModelAdminMixin, admin.StackedInline):
pass
class ObjectPermissionsTabularInline(ObjectPermissionsInlineModelAdminMixin, admin.TabularInline):
pass
<|fim▁end|> | return '%s_%s' % (action, opts.object_name.lower()) |
<|file_name|>admin.py<|end_file_name|><|fim▁begin|>from django.contrib import admin
try:
from django.contrib.auth import get_permission_codename
except ImportError: # pragma: no cover
# Django < 1.6
def get_permission_codename(action, opts):
return '%s_%s' % (action, opts.object_name.lower())
class ObjectPermissionsModelAdminMixin(object):
<|fim_middle|>
class ObjectPermissionsInlineModelAdminMixin(ObjectPermissionsModelAdminMixin):
def has_change_permission(self, request, obj=None): # pragma: no cover
opts = self.opts
if opts.auto_created:
for field in opts.fields:
if field.rel and field.rel.to != self.parent_model:
opts = field.rel.to._meta
break
codename = get_permission_codename('change', opts)
return request.user.has_perm('%s.%s' % (opts.app_label, codename), obj)
def has_delete_permission(self, request, obj=None): # pragma: no cover
if self.opts.auto_created:
return self.has_change_permission(request, obj)
return super(ObjectPermissionsInlineModelAdminMixin, self).has_delete_permission(request, obj)
class ObjectPermissionsModelAdmin(ObjectPermissionsModelAdminMixin, admin.ModelAdmin):
pass
class ObjectPermissionsStackedInline(ObjectPermissionsInlineModelAdminMixin, admin.StackedInline):
pass
class ObjectPermissionsTabularInline(ObjectPermissionsInlineModelAdminMixin, admin.TabularInline):
pass
<|fim▁end|> | def has_change_permission(self, request, obj=None):
opts = self.opts
codename = get_permission_codename('change', opts)
return request.user.has_perm('%s.%s' % (opts.app_label, codename), obj)
def has_delete_permission(self, request, obj=None):
opts = self.opts
codename = get_permission_codename('delete', opts)
return request.user.has_perm('%s.%s' % (opts.app_label, codename), obj) |
<|file_name|>admin.py<|end_file_name|><|fim▁begin|>from django.contrib import admin
try:
from django.contrib.auth import get_permission_codename
except ImportError: # pragma: no cover
# Django < 1.6
def get_permission_codename(action, opts):
return '%s_%s' % (action, opts.object_name.lower())
class ObjectPermissionsModelAdminMixin(object):
def has_change_permission(self, request, obj=None):
<|fim_middle|>
def has_delete_permission(self, request, obj=None):
opts = self.opts
codename = get_permission_codename('delete', opts)
return request.user.has_perm('%s.%s' % (opts.app_label, codename), obj)
class ObjectPermissionsInlineModelAdminMixin(ObjectPermissionsModelAdminMixin):
def has_change_permission(self, request, obj=None): # pragma: no cover
opts = self.opts
if opts.auto_created:
for field in opts.fields:
if field.rel and field.rel.to != self.parent_model:
opts = field.rel.to._meta
break
codename = get_permission_codename('change', opts)
return request.user.has_perm('%s.%s' % (opts.app_label, codename), obj)
def has_delete_permission(self, request, obj=None): # pragma: no cover
if self.opts.auto_created:
return self.has_change_permission(request, obj)
return super(ObjectPermissionsInlineModelAdminMixin, self).has_delete_permission(request, obj)
class ObjectPermissionsModelAdmin(ObjectPermissionsModelAdminMixin, admin.ModelAdmin):
pass
class ObjectPermissionsStackedInline(ObjectPermissionsInlineModelAdminMixin, admin.StackedInline):
pass
class ObjectPermissionsTabularInline(ObjectPermissionsInlineModelAdminMixin, admin.TabularInline):
pass
<|fim▁end|> | opts = self.opts
codename = get_permission_codename('change', opts)
return request.user.has_perm('%s.%s' % (opts.app_label, codename), obj) |
<|file_name|>admin.py<|end_file_name|><|fim▁begin|>from django.contrib import admin
try:
from django.contrib.auth import get_permission_codename
except ImportError: # pragma: no cover
# Django < 1.6
def get_permission_codename(action, opts):
return '%s_%s' % (action, opts.object_name.lower())
class ObjectPermissionsModelAdminMixin(object):
def has_change_permission(self, request, obj=None):
opts = self.opts
codename = get_permission_codename('change', opts)
return request.user.has_perm('%s.%s' % (opts.app_label, codename), obj)
def has_delete_permission(self, request, obj=None):
<|fim_middle|>
class ObjectPermissionsInlineModelAdminMixin(ObjectPermissionsModelAdminMixin):
def has_change_permission(self, request, obj=None): # pragma: no cover
opts = self.opts
if opts.auto_created:
for field in opts.fields:
if field.rel and field.rel.to != self.parent_model:
opts = field.rel.to._meta
break
codename = get_permission_codename('change', opts)
return request.user.has_perm('%s.%s' % (opts.app_label, codename), obj)
def has_delete_permission(self, request, obj=None): # pragma: no cover
if self.opts.auto_created:
return self.has_change_permission(request, obj)
return super(ObjectPermissionsInlineModelAdminMixin, self).has_delete_permission(request, obj)
class ObjectPermissionsModelAdmin(ObjectPermissionsModelAdminMixin, admin.ModelAdmin):
pass
class ObjectPermissionsStackedInline(ObjectPermissionsInlineModelAdminMixin, admin.StackedInline):
pass
class ObjectPermissionsTabularInline(ObjectPermissionsInlineModelAdminMixin, admin.TabularInline):
pass
<|fim▁end|> | opts = self.opts
codename = get_permission_codename('delete', opts)
return request.user.has_perm('%s.%s' % (opts.app_label, codename), obj) |
<|file_name|>admin.py<|end_file_name|><|fim▁begin|>from django.contrib import admin
try:
from django.contrib.auth import get_permission_codename
except ImportError: # pragma: no cover
# Django < 1.6
def get_permission_codename(action, opts):
return '%s_%s' % (action, opts.object_name.lower())
class ObjectPermissionsModelAdminMixin(object):
def has_change_permission(self, request, obj=None):
opts = self.opts
codename = get_permission_codename('change', opts)
return request.user.has_perm('%s.%s' % (opts.app_label, codename), obj)
def has_delete_permission(self, request, obj=None):
opts = self.opts
codename = get_permission_codename('delete', opts)
return request.user.has_perm('%s.%s' % (opts.app_label, codename), obj)
class ObjectPermissionsInlineModelAdminMixin(ObjectPermissionsModelAdminMixin):
<|fim_middle|>
class ObjectPermissionsModelAdmin(ObjectPermissionsModelAdminMixin, admin.ModelAdmin):
pass
class ObjectPermissionsStackedInline(ObjectPermissionsInlineModelAdminMixin, admin.StackedInline):
pass
class ObjectPermissionsTabularInline(ObjectPermissionsInlineModelAdminMixin, admin.TabularInline):
pass
<|fim▁end|> | def has_change_permission(self, request, obj=None): # pragma: no cover
opts = self.opts
if opts.auto_created:
for field in opts.fields:
if field.rel and field.rel.to != self.parent_model:
opts = field.rel.to._meta
break
codename = get_permission_codename('change', opts)
return request.user.has_perm('%s.%s' % (opts.app_label, codename), obj)
def has_delete_permission(self, request, obj=None): # pragma: no cover
if self.opts.auto_created:
return self.has_change_permission(request, obj)
return super(ObjectPermissionsInlineModelAdminMixin, self).has_delete_permission(request, obj) |
<|file_name|>admin.py<|end_file_name|><|fim▁begin|>from django.contrib import admin
try:
from django.contrib.auth import get_permission_codename
except ImportError: # pragma: no cover
# Django < 1.6
def get_permission_codename(action, opts):
return '%s_%s' % (action, opts.object_name.lower())
class ObjectPermissionsModelAdminMixin(object):
def has_change_permission(self, request, obj=None):
opts = self.opts
codename = get_permission_codename('change', opts)
return request.user.has_perm('%s.%s' % (opts.app_label, codename), obj)
def has_delete_permission(self, request, obj=None):
opts = self.opts
codename = get_permission_codename('delete', opts)
return request.user.has_perm('%s.%s' % (opts.app_label, codename), obj)
class ObjectPermissionsInlineModelAdminMixin(ObjectPermissionsModelAdminMixin):
def has_change_permission(self, request, obj=None): # pragma: no cover
<|fim_middle|>
def has_delete_permission(self, request, obj=None): # pragma: no cover
if self.opts.auto_created:
return self.has_change_permission(request, obj)
return super(ObjectPermissionsInlineModelAdminMixin, self).has_delete_permission(request, obj)
class ObjectPermissionsModelAdmin(ObjectPermissionsModelAdminMixin, admin.ModelAdmin):
pass
class ObjectPermissionsStackedInline(ObjectPermissionsInlineModelAdminMixin, admin.StackedInline):
pass
class ObjectPermissionsTabularInline(ObjectPermissionsInlineModelAdminMixin, admin.TabularInline):
pass
<|fim▁end|> | opts = self.opts
if opts.auto_created:
for field in opts.fields:
if field.rel and field.rel.to != self.parent_model:
opts = field.rel.to._meta
break
codename = get_permission_codename('change', opts)
return request.user.has_perm('%s.%s' % (opts.app_label, codename), obj) |
<|file_name|>admin.py<|end_file_name|><|fim▁begin|>from django.contrib import admin
try:
from django.contrib.auth import get_permission_codename
except ImportError: # pragma: no cover
# Django < 1.6
def get_permission_codename(action, opts):
return '%s_%s' % (action, opts.object_name.lower())
class ObjectPermissionsModelAdminMixin(object):
def has_change_permission(self, request, obj=None):
opts = self.opts
codename = get_permission_codename('change', opts)
return request.user.has_perm('%s.%s' % (opts.app_label, codename), obj)
def has_delete_permission(self, request, obj=None):
opts = self.opts
codename = get_permission_codename('delete', opts)
return request.user.has_perm('%s.%s' % (opts.app_label, codename), obj)
class ObjectPermissionsInlineModelAdminMixin(ObjectPermissionsModelAdminMixin):
def has_change_permission(self, request, obj=None): # pragma: no cover
opts = self.opts
if opts.auto_created:
for field in opts.fields:
if field.rel and field.rel.to != self.parent_model:
opts = field.rel.to._meta
break
codename = get_permission_codename('change', opts)
return request.user.has_perm('%s.%s' % (opts.app_label, codename), obj)
def has_delete_permission(self, request, obj=None): # pragma: no cover
<|fim_middle|>
class ObjectPermissionsModelAdmin(ObjectPermissionsModelAdminMixin, admin.ModelAdmin):
pass
class ObjectPermissionsStackedInline(ObjectPermissionsInlineModelAdminMixin, admin.StackedInline):
pass
class ObjectPermissionsTabularInline(ObjectPermissionsInlineModelAdminMixin, admin.TabularInline):
pass
<|fim▁end|> | if self.opts.auto_created:
return self.has_change_permission(request, obj)
return super(ObjectPermissionsInlineModelAdminMixin, self).has_delete_permission(request, obj) |
<|file_name|>admin.py<|end_file_name|><|fim▁begin|>from django.contrib import admin
try:
from django.contrib.auth import get_permission_codename
except ImportError: # pragma: no cover
# Django < 1.6
def get_permission_codename(action, opts):
return '%s_%s' % (action, opts.object_name.lower())
class ObjectPermissionsModelAdminMixin(object):
def has_change_permission(self, request, obj=None):
opts = self.opts
codename = get_permission_codename('change', opts)
return request.user.has_perm('%s.%s' % (opts.app_label, codename), obj)
def has_delete_permission(self, request, obj=None):
opts = self.opts
codename = get_permission_codename('delete', opts)
return request.user.has_perm('%s.%s' % (opts.app_label, codename), obj)
class ObjectPermissionsInlineModelAdminMixin(ObjectPermissionsModelAdminMixin):
def has_change_permission(self, request, obj=None): # pragma: no cover
opts = self.opts
if opts.auto_created:
for field in opts.fields:
if field.rel and field.rel.to != self.parent_model:
opts = field.rel.to._meta
break
codename = get_permission_codename('change', opts)
return request.user.has_perm('%s.%s' % (opts.app_label, codename), obj)
def has_delete_permission(self, request, obj=None): # pragma: no cover
if self.opts.auto_created:
return self.has_change_permission(request, obj)
return super(ObjectPermissionsInlineModelAdminMixin, self).has_delete_permission(request, obj)
class ObjectPermissionsModelAdmin(ObjectPermissionsModelAdminMixin, admin.ModelAdmin):
<|fim_middle|>
class ObjectPermissionsStackedInline(ObjectPermissionsInlineModelAdminMixin, admin.StackedInline):
pass
class ObjectPermissionsTabularInline(ObjectPermissionsInlineModelAdminMixin, admin.TabularInline):
pass
<|fim▁end|> | pass |
<|file_name|>admin.py<|end_file_name|><|fim▁begin|>from django.contrib import admin
try:
from django.contrib.auth import get_permission_codename
except ImportError: # pragma: no cover
# Django < 1.6
def get_permission_codename(action, opts):
return '%s_%s' % (action, opts.object_name.lower())
class ObjectPermissionsModelAdminMixin(object):
def has_change_permission(self, request, obj=None):
opts = self.opts
codename = get_permission_codename('change', opts)
return request.user.has_perm('%s.%s' % (opts.app_label, codename), obj)
def has_delete_permission(self, request, obj=None):
opts = self.opts
codename = get_permission_codename('delete', opts)
return request.user.has_perm('%s.%s' % (opts.app_label, codename), obj)
class ObjectPermissionsInlineModelAdminMixin(ObjectPermissionsModelAdminMixin):
def has_change_permission(self, request, obj=None): # pragma: no cover
opts = self.opts
if opts.auto_created:
for field in opts.fields:
if field.rel and field.rel.to != self.parent_model:
opts = field.rel.to._meta
break
codename = get_permission_codename('change', opts)
return request.user.has_perm('%s.%s' % (opts.app_label, codename), obj)
def has_delete_permission(self, request, obj=None): # pragma: no cover
if self.opts.auto_created:
return self.has_change_permission(request, obj)
return super(ObjectPermissionsInlineModelAdminMixin, self).has_delete_permission(request, obj)
class ObjectPermissionsModelAdmin(ObjectPermissionsModelAdminMixin, admin.ModelAdmin):
pass
class ObjectPermissionsStackedInline(ObjectPermissionsInlineModelAdminMixin, admin.StackedInline):
<|fim_middle|>
class ObjectPermissionsTabularInline(ObjectPermissionsInlineModelAdminMixin, admin.TabularInline):
pass
<|fim▁end|> | pass |
<|file_name|>admin.py<|end_file_name|><|fim▁begin|>from django.contrib import admin
try:
from django.contrib.auth import get_permission_codename
except ImportError: # pragma: no cover
# Django < 1.6
def get_permission_codename(action, opts):
return '%s_%s' % (action, opts.object_name.lower())
class ObjectPermissionsModelAdminMixin(object):
def has_change_permission(self, request, obj=None):
opts = self.opts
codename = get_permission_codename('change', opts)
return request.user.has_perm('%s.%s' % (opts.app_label, codename), obj)
def has_delete_permission(self, request, obj=None):
opts = self.opts
codename = get_permission_codename('delete', opts)
return request.user.has_perm('%s.%s' % (opts.app_label, codename), obj)
class ObjectPermissionsInlineModelAdminMixin(ObjectPermissionsModelAdminMixin):
def has_change_permission(self, request, obj=None): # pragma: no cover
opts = self.opts
if opts.auto_created:
for field in opts.fields:
if field.rel and field.rel.to != self.parent_model:
opts = field.rel.to._meta
break
codename = get_permission_codename('change', opts)
return request.user.has_perm('%s.%s' % (opts.app_label, codename), obj)
def has_delete_permission(self, request, obj=None): # pragma: no cover
if self.opts.auto_created:
return self.has_change_permission(request, obj)
return super(ObjectPermissionsInlineModelAdminMixin, self).has_delete_permission(request, obj)
class ObjectPermissionsModelAdmin(ObjectPermissionsModelAdminMixin, admin.ModelAdmin):
pass
class ObjectPermissionsStackedInline(ObjectPermissionsInlineModelAdminMixin, admin.StackedInline):
pass
class ObjectPermissionsTabularInline(ObjectPermissionsInlineModelAdminMixin, admin.TabularInline):
<|fim_middle|>
<|fim▁end|> | pass |
<|file_name|>admin.py<|end_file_name|><|fim▁begin|>from django.contrib import admin
try:
from django.contrib.auth import get_permission_codename
except ImportError: # pragma: no cover
# Django < 1.6
def get_permission_codename(action, opts):
return '%s_%s' % (action, opts.object_name.lower())
class ObjectPermissionsModelAdminMixin(object):
def has_change_permission(self, request, obj=None):
opts = self.opts
codename = get_permission_codename('change', opts)
return request.user.has_perm('%s.%s' % (opts.app_label, codename), obj)
def has_delete_permission(self, request, obj=None):
opts = self.opts
codename = get_permission_codename('delete', opts)
return request.user.has_perm('%s.%s' % (opts.app_label, codename), obj)
class ObjectPermissionsInlineModelAdminMixin(ObjectPermissionsModelAdminMixin):
def has_change_permission(self, request, obj=None): # pragma: no cover
opts = self.opts
if opts.auto_created:
<|fim_middle|>
codename = get_permission_codename('change', opts)
return request.user.has_perm('%s.%s' % (opts.app_label, codename), obj)
def has_delete_permission(self, request, obj=None): # pragma: no cover
if self.opts.auto_created:
return self.has_change_permission(request, obj)
return super(ObjectPermissionsInlineModelAdminMixin, self).has_delete_permission(request, obj)
class ObjectPermissionsModelAdmin(ObjectPermissionsModelAdminMixin, admin.ModelAdmin):
pass
class ObjectPermissionsStackedInline(ObjectPermissionsInlineModelAdminMixin, admin.StackedInline):
pass
class ObjectPermissionsTabularInline(ObjectPermissionsInlineModelAdminMixin, admin.TabularInline):
pass
<|fim▁end|> | for field in opts.fields:
if field.rel and field.rel.to != self.parent_model:
opts = field.rel.to._meta
break |
<|file_name|>admin.py<|end_file_name|><|fim▁begin|>from django.contrib import admin
try:
from django.contrib.auth import get_permission_codename
except ImportError: # pragma: no cover
# Django < 1.6
def get_permission_codename(action, opts):
return '%s_%s' % (action, opts.object_name.lower())
class ObjectPermissionsModelAdminMixin(object):
def has_change_permission(self, request, obj=None):
opts = self.opts
codename = get_permission_codename('change', opts)
return request.user.has_perm('%s.%s' % (opts.app_label, codename), obj)
def has_delete_permission(self, request, obj=None):
opts = self.opts
codename = get_permission_codename('delete', opts)
return request.user.has_perm('%s.%s' % (opts.app_label, codename), obj)
class ObjectPermissionsInlineModelAdminMixin(ObjectPermissionsModelAdminMixin):
def has_change_permission(self, request, obj=None): # pragma: no cover
opts = self.opts
if opts.auto_created:
for field in opts.fields:
if field.rel and field.rel.to != self.parent_model:
<|fim_middle|>
codename = get_permission_codename('change', opts)
return request.user.has_perm('%s.%s' % (opts.app_label, codename), obj)
def has_delete_permission(self, request, obj=None): # pragma: no cover
if self.opts.auto_created:
return self.has_change_permission(request, obj)
return super(ObjectPermissionsInlineModelAdminMixin, self).has_delete_permission(request, obj)
class ObjectPermissionsModelAdmin(ObjectPermissionsModelAdminMixin, admin.ModelAdmin):
pass
class ObjectPermissionsStackedInline(ObjectPermissionsInlineModelAdminMixin, admin.StackedInline):
pass
class ObjectPermissionsTabularInline(ObjectPermissionsInlineModelAdminMixin, admin.TabularInline):
pass
<|fim▁end|> | opts = field.rel.to._meta
break |
<|file_name|>admin.py<|end_file_name|><|fim▁begin|>from django.contrib import admin
try:
from django.contrib.auth import get_permission_codename
except ImportError: # pragma: no cover
# Django < 1.6
def get_permission_codename(action, opts):
return '%s_%s' % (action, opts.object_name.lower())
class ObjectPermissionsModelAdminMixin(object):
def has_change_permission(self, request, obj=None):
opts = self.opts
codename = get_permission_codename('change', opts)
return request.user.has_perm('%s.%s' % (opts.app_label, codename), obj)
def has_delete_permission(self, request, obj=None):
opts = self.opts
codename = get_permission_codename('delete', opts)
return request.user.has_perm('%s.%s' % (opts.app_label, codename), obj)
class ObjectPermissionsInlineModelAdminMixin(ObjectPermissionsModelAdminMixin):
def has_change_permission(self, request, obj=None): # pragma: no cover
opts = self.opts
if opts.auto_created:
for field in opts.fields:
if field.rel and field.rel.to != self.parent_model:
opts = field.rel.to._meta
break
codename = get_permission_codename('change', opts)
return request.user.has_perm('%s.%s' % (opts.app_label, codename), obj)
def has_delete_permission(self, request, obj=None): # pragma: no cover
if self.opts.auto_created:
<|fim_middle|>
return super(ObjectPermissionsInlineModelAdminMixin, self).has_delete_permission(request, obj)
class ObjectPermissionsModelAdmin(ObjectPermissionsModelAdminMixin, admin.ModelAdmin):
pass
class ObjectPermissionsStackedInline(ObjectPermissionsInlineModelAdminMixin, admin.StackedInline):
pass
class ObjectPermissionsTabularInline(ObjectPermissionsInlineModelAdminMixin, admin.TabularInline):
pass
<|fim▁end|> | return self.has_change_permission(request, obj) |
<|file_name|>admin.py<|end_file_name|><|fim▁begin|>from django.contrib import admin
try:
from django.contrib.auth import get_permission_codename
except ImportError: # pragma: no cover
# Django < 1.6
def <|fim_middle|>(action, opts):
return '%s_%s' % (action, opts.object_name.lower())
class ObjectPermissionsModelAdminMixin(object):
def has_change_permission(self, request, obj=None):
opts = self.opts
codename = get_permission_codename('change', opts)
return request.user.has_perm('%s.%s' % (opts.app_label, codename), obj)
def has_delete_permission(self, request, obj=None):
opts = self.opts
codename = get_permission_codename('delete', opts)
return request.user.has_perm('%s.%s' % (opts.app_label, codename), obj)
class ObjectPermissionsInlineModelAdminMixin(ObjectPermissionsModelAdminMixin):
def has_change_permission(self, request, obj=None): # pragma: no cover
opts = self.opts
if opts.auto_created:
for field in opts.fields:
if field.rel and field.rel.to != self.parent_model:
opts = field.rel.to._meta
break
codename = get_permission_codename('change', opts)
return request.user.has_perm('%s.%s' % (opts.app_label, codename), obj)
def has_delete_permission(self, request, obj=None): # pragma: no cover
if self.opts.auto_created:
return self.has_change_permission(request, obj)
return super(ObjectPermissionsInlineModelAdminMixin, self).has_delete_permission(request, obj)
class ObjectPermissionsModelAdmin(ObjectPermissionsModelAdminMixin, admin.ModelAdmin):
pass
class ObjectPermissionsStackedInline(ObjectPermissionsInlineModelAdminMixin, admin.StackedInline):
pass
class ObjectPermissionsTabularInline(ObjectPermissionsInlineModelAdminMixin, admin.TabularInline):
pass
<|fim▁end|> | get_permission_codename |
<|file_name|>admin.py<|end_file_name|><|fim▁begin|>from django.contrib import admin
try:
from django.contrib.auth import get_permission_codename
except ImportError: # pragma: no cover
# Django < 1.6
def get_permission_codename(action, opts):
return '%s_%s' % (action, opts.object_name.lower())
class ObjectPermissionsModelAdminMixin(object):
def <|fim_middle|>(self, request, obj=None):
opts = self.opts
codename = get_permission_codename('change', opts)
return request.user.has_perm('%s.%s' % (opts.app_label, codename), obj)
def has_delete_permission(self, request, obj=None):
opts = self.opts
codename = get_permission_codename('delete', opts)
return request.user.has_perm('%s.%s' % (opts.app_label, codename), obj)
class ObjectPermissionsInlineModelAdminMixin(ObjectPermissionsModelAdminMixin):
def has_change_permission(self, request, obj=None): # pragma: no cover
opts = self.opts
if opts.auto_created:
for field in opts.fields:
if field.rel and field.rel.to != self.parent_model:
opts = field.rel.to._meta
break
codename = get_permission_codename('change', opts)
return request.user.has_perm('%s.%s' % (opts.app_label, codename), obj)
def has_delete_permission(self, request, obj=None): # pragma: no cover
if self.opts.auto_created:
return self.has_change_permission(request, obj)
return super(ObjectPermissionsInlineModelAdminMixin, self).has_delete_permission(request, obj)
class ObjectPermissionsModelAdmin(ObjectPermissionsModelAdminMixin, admin.ModelAdmin):
pass
class ObjectPermissionsStackedInline(ObjectPermissionsInlineModelAdminMixin, admin.StackedInline):
pass
class ObjectPermissionsTabularInline(ObjectPermissionsInlineModelAdminMixin, admin.TabularInline):
pass
<|fim▁end|> | has_change_permission |
<|file_name|>admin.py<|end_file_name|><|fim▁begin|>from django.contrib import admin
try:
from django.contrib.auth import get_permission_codename
except ImportError: # pragma: no cover
# Django < 1.6
def get_permission_codename(action, opts):
return '%s_%s' % (action, opts.object_name.lower())
class ObjectPermissionsModelAdminMixin(object):
def has_change_permission(self, request, obj=None):
opts = self.opts
codename = get_permission_codename('change', opts)
return request.user.has_perm('%s.%s' % (opts.app_label, codename), obj)
def <|fim_middle|>(self, request, obj=None):
opts = self.opts
codename = get_permission_codename('delete', opts)
return request.user.has_perm('%s.%s' % (opts.app_label, codename), obj)
class ObjectPermissionsInlineModelAdminMixin(ObjectPermissionsModelAdminMixin):
def has_change_permission(self, request, obj=None): # pragma: no cover
opts = self.opts
if opts.auto_created:
for field in opts.fields:
if field.rel and field.rel.to != self.parent_model:
opts = field.rel.to._meta
break
codename = get_permission_codename('change', opts)
return request.user.has_perm('%s.%s' % (opts.app_label, codename), obj)
def has_delete_permission(self, request, obj=None): # pragma: no cover
if self.opts.auto_created:
return self.has_change_permission(request, obj)
return super(ObjectPermissionsInlineModelAdminMixin, self).has_delete_permission(request, obj)
class ObjectPermissionsModelAdmin(ObjectPermissionsModelAdminMixin, admin.ModelAdmin):
pass
class ObjectPermissionsStackedInline(ObjectPermissionsInlineModelAdminMixin, admin.StackedInline):
pass
class ObjectPermissionsTabularInline(ObjectPermissionsInlineModelAdminMixin, admin.TabularInline):
pass
<|fim▁end|> | has_delete_permission |
<|file_name|>admin.py<|end_file_name|><|fim▁begin|>from django.contrib import admin
try:
from django.contrib.auth import get_permission_codename
except ImportError: # pragma: no cover
# Django < 1.6
def get_permission_codename(action, opts):
return '%s_%s' % (action, opts.object_name.lower())
class ObjectPermissionsModelAdminMixin(object):
def has_change_permission(self, request, obj=None):
opts = self.opts
codename = get_permission_codename('change', opts)
return request.user.has_perm('%s.%s' % (opts.app_label, codename), obj)
def has_delete_permission(self, request, obj=None):
opts = self.opts
codename = get_permission_codename('delete', opts)
return request.user.has_perm('%s.%s' % (opts.app_label, codename), obj)
class ObjectPermissionsInlineModelAdminMixin(ObjectPermissionsModelAdminMixin):
def <|fim_middle|>(self, request, obj=None): # pragma: no cover
opts = self.opts
if opts.auto_created:
for field in opts.fields:
if field.rel and field.rel.to != self.parent_model:
opts = field.rel.to._meta
break
codename = get_permission_codename('change', opts)
return request.user.has_perm('%s.%s' % (opts.app_label, codename), obj)
def has_delete_permission(self, request, obj=None): # pragma: no cover
if self.opts.auto_created:
return self.has_change_permission(request, obj)
return super(ObjectPermissionsInlineModelAdminMixin, self).has_delete_permission(request, obj)
class ObjectPermissionsModelAdmin(ObjectPermissionsModelAdminMixin, admin.ModelAdmin):
pass
class ObjectPermissionsStackedInline(ObjectPermissionsInlineModelAdminMixin, admin.StackedInline):
pass
class ObjectPermissionsTabularInline(ObjectPermissionsInlineModelAdminMixin, admin.TabularInline):
pass
<|fim▁end|> | has_change_permission |
<|file_name|>admin.py<|end_file_name|><|fim▁begin|>from django.contrib import admin
try:
from django.contrib.auth import get_permission_codename
except ImportError: # pragma: no cover
# Django < 1.6
def get_permission_codename(action, opts):
return '%s_%s' % (action, opts.object_name.lower())
class ObjectPermissionsModelAdminMixin(object):
def has_change_permission(self, request, obj=None):
opts = self.opts
codename = get_permission_codename('change', opts)
return request.user.has_perm('%s.%s' % (opts.app_label, codename), obj)
def has_delete_permission(self, request, obj=None):
opts = self.opts
codename = get_permission_codename('delete', opts)
return request.user.has_perm('%s.%s' % (opts.app_label, codename), obj)
class ObjectPermissionsInlineModelAdminMixin(ObjectPermissionsModelAdminMixin):
def has_change_permission(self, request, obj=None): # pragma: no cover
opts = self.opts
if opts.auto_created:
for field in opts.fields:
if field.rel and field.rel.to != self.parent_model:
opts = field.rel.to._meta
break
codename = get_permission_codename('change', opts)
return request.user.has_perm('%s.%s' % (opts.app_label, codename), obj)
def <|fim_middle|>(self, request, obj=None): # pragma: no cover
if self.opts.auto_created:
return self.has_change_permission(request, obj)
return super(ObjectPermissionsInlineModelAdminMixin, self).has_delete_permission(request, obj)
class ObjectPermissionsModelAdmin(ObjectPermissionsModelAdminMixin, admin.ModelAdmin):
pass
class ObjectPermissionsStackedInline(ObjectPermissionsInlineModelAdminMixin, admin.StackedInline):
pass
class ObjectPermissionsTabularInline(ObjectPermissionsInlineModelAdminMixin, admin.TabularInline):
pass
<|fim▁end|> | has_delete_permission |
<|file_name|>hook-carchive.py<|end_file_name|><|fim▁begin|># Copyright (C) 2005, Giovanni Bajo
# Based on previous work under copyright (c) 2001, 2002 McMillan Enterprises, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#<|fim▁hole|># You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
import sys
def hook(mod):
if sys.version[0] > '1':
for i in range(len(mod.imports)-1, -1, -1):
if mod.imports[i][0] == 'strop':
del mod.imports[i]
return mod<|fim▁end|> | |
<|file_name|>hook-carchive.py<|end_file_name|><|fim▁begin|># Copyright (C) 2005, Giovanni Bajo
# Based on previous work under copyright (c) 2001, 2002 McMillan Enterprises, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
import sys
def hook(mod):
<|fim_middle|>
<|fim▁end|> | if sys.version[0] > '1':
for i in range(len(mod.imports)-1, -1, -1):
if mod.imports[i][0] == 'strop':
del mod.imports[i]
return mod |
<|file_name|>hook-carchive.py<|end_file_name|><|fim▁begin|># Copyright (C) 2005, Giovanni Bajo
# Based on previous work under copyright (c) 2001, 2002 McMillan Enterprises, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
import sys
def hook(mod):
if sys.version[0] > '1':
<|fim_middle|>
return mod
<|fim▁end|> | for i in range(len(mod.imports)-1, -1, -1):
if mod.imports[i][0] == 'strop':
del mod.imports[i] |
<|file_name|>hook-carchive.py<|end_file_name|><|fim▁begin|># Copyright (C) 2005, Giovanni Bajo
# Based on previous work under copyright (c) 2001, 2002 McMillan Enterprises, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
import sys
def hook(mod):
if sys.version[0] > '1':
for i in range(len(mod.imports)-1, -1, -1):
if mod.imports[i][0] == 'strop':
<|fim_middle|>
return mod
<|fim▁end|> | del mod.imports[i] |
<|file_name|>hook-carchive.py<|end_file_name|><|fim▁begin|># Copyright (C) 2005, Giovanni Bajo
# Based on previous work under copyright (c) 2001, 2002 McMillan Enterprises, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
import sys
def <|fim_middle|>(mod):
if sys.version[0] > '1':
for i in range(len(mod.imports)-1, -1, -1):
if mod.imports[i][0] == 'strop':
del mod.imports[i]
return mod
<|fim▁end|> | hook |
<|file_name|>keys.py<|end_file_name|><|fim▁begin|>Alchemy sentiment analysis: fb12d2c55fff36e1e268584e261b6b010b37279f
<|fim▁hole|>
Africa Is Talking: 676dbd926bbb04fa69ce90ee81d3f5ffee2692aaf80eb5793bd70fe93e77dc2e<|fim▁end|> | |
<|file_name|>pluginFitSigmoidal.py<|end_file_name|><|fim▁begin|>#--------------------------------------------------<|fim▁hole|># Revision = $Rev: 20 $
# Date = $Date: 2011-08-05 20:42:24 +0200 (Fri, 05 Aug 2011) $
# Author = $Author: stefan $
#--------------------------------------------------
from pluginInterfaces import PluginFit, Parameter,leastsqFit
import numpy as np
class PluginFitThreeBodyBeta(PluginFit):
def __init__(self):
pass
def fit(self,array,errarray,param,xmin=0,xmax=0, fitAxes=[]):
"""return the data that is needed for plotting the fitting result"""
"""0...a, 1...xc, 2...k, 3...y0"""
self.params = [Parameter(v) for v in param]
def f(x): return self.params[0]()/(1+np.exp(-(x-self.params[1]())/self.params[2]()))+self.params[3]()
self.simpleFitAllAxes(f,array,errarray,xmin,xmax, fitAxes)
return self.generateDataFromParameters(f,[np.amin(array[0,:]),np.amax(array[0,:])], np.size(fitAxes)+1, xmin, xmax, fitAxes)
def getInitialParameters(self,data):
"""find the best initial values and return them"""
dx = np.abs(data[0,0] - data[0,-1])
mi = np.amin(data[1,:])
ma = np.amax(data[1,:])
xc = (np.amax(data[0,:])-np.amin(data[0,:]))/2+np.amin(data[0,:])
return [ma-mi,xc,dx*2,mi]
def getParameters(self):
"""return the fit parameters"""
return np.array(["a","xc","dx","y0"])
def getFitModelStr(self):
"""return a string of the implemented fitting model, i.e. 'linear fit (y=A*x +B)'"""
return "Sigmoidal"
def getResultStr(self):
"""return a special result, i.e. 'Frequency = blabla'"""
return "nothing fitted"<|fim▁end|> | |
<|file_name|>pluginFitSigmoidal.py<|end_file_name|><|fim▁begin|>#--------------------------------------------------
# Revision = $Rev: 20 $
# Date = $Date: 2011-08-05 20:42:24 +0200 (Fri, 05 Aug 2011) $
# Author = $Author: stefan $
#--------------------------------------------------
from pluginInterfaces import PluginFit, Parameter,leastsqFit
import numpy as np
class PluginFitThreeBodyBeta(PluginFit):
<|fim_middle|>
<|fim▁end|> | def __init__(self):
pass
def fit(self,array,errarray,param,xmin=0,xmax=0, fitAxes=[]):
"""return the data that is needed for plotting the fitting result"""
"""0...a, 1...xc, 2...k, 3...y0"""
self.params = [Parameter(v) for v in param]
def f(x): return self.params[0]()/(1+np.exp(-(x-self.params[1]())/self.params[2]()))+self.params[3]()
self.simpleFitAllAxes(f,array,errarray,xmin,xmax, fitAxes)
return self.generateDataFromParameters(f,[np.amin(array[0,:]),np.amax(array[0,:])], np.size(fitAxes)+1, xmin, xmax, fitAxes)
def getInitialParameters(self,data):
"""find the best initial values and return them"""
dx = np.abs(data[0,0] - data[0,-1])
mi = np.amin(data[1,:])
ma = np.amax(data[1,:])
xc = (np.amax(data[0,:])-np.amin(data[0,:]))/2+np.amin(data[0,:])
return [ma-mi,xc,dx*2,mi]
def getParameters(self):
"""return the fit parameters"""
return np.array(["a","xc","dx","y0"])
def getFitModelStr(self):
"""return a string of the implemented fitting model, i.e. 'linear fit (y=A*x +B)'"""
return "Sigmoidal"
def getResultStr(self):
"""return a special result, i.e. 'Frequency = blabla'"""
return "nothing fitted" |
<|file_name|>pluginFitSigmoidal.py<|end_file_name|><|fim▁begin|>#--------------------------------------------------
# Revision = $Rev: 20 $
# Date = $Date: 2011-08-05 20:42:24 +0200 (Fri, 05 Aug 2011) $
# Author = $Author: stefan $
#--------------------------------------------------
from pluginInterfaces import PluginFit, Parameter,leastsqFit
import numpy as np
class PluginFitThreeBodyBeta(PluginFit):
def __init__(self):
<|fim_middle|>
def fit(self,array,errarray,param,xmin=0,xmax=0, fitAxes=[]):
"""return the data that is needed for plotting the fitting result"""
"""0...a, 1...xc, 2...k, 3...y0"""
self.params = [Parameter(v) for v in param]
def f(x): return self.params[0]()/(1+np.exp(-(x-self.params[1]())/self.params[2]()))+self.params[3]()
self.simpleFitAllAxes(f,array,errarray,xmin,xmax, fitAxes)
return self.generateDataFromParameters(f,[np.amin(array[0,:]),np.amax(array[0,:])], np.size(fitAxes)+1, xmin, xmax, fitAxes)
def getInitialParameters(self,data):
"""find the best initial values and return them"""
dx = np.abs(data[0,0] - data[0,-1])
mi = np.amin(data[1,:])
ma = np.amax(data[1,:])
xc = (np.amax(data[0,:])-np.amin(data[0,:]))/2+np.amin(data[0,:])
return [ma-mi,xc,dx*2,mi]
def getParameters(self):
"""return the fit parameters"""
return np.array(["a","xc","dx","y0"])
def getFitModelStr(self):
"""return a string of the implemented fitting model, i.e. 'linear fit (y=A*x +B)'"""
return "Sigmoidal"
def getResultStr(self):
"""return a special result, i.e. 'Frequency = blabla'"""
return "nothing fitted"
<|fim▁end|> | pass |
<|file_name|>pluginFitSigmoidal.py<|end_file_name|><|fim▁begin|>#--------------------------------------------------
# Revision = $Rev: 20 $
# Date = $Date: 2011-08-05 20:42:24 +0200 (Fri, 05 Aug 2011) $
# Author = $Author: stefan $
#--------------------------------------------------
from pluginInterfaces import PluginFit, Parameter,leastsqFit
import numpy as np
class PluginFitThreeBodyBeta(PluginFit):
def __init__(self):
pass
def fit(self,array,errarray,param,xmin=0,xmax=0, fitAxes=[]):
<|fim_middle|>
def getInitialParameters(self,data):
"""find the best initial values and return them"""
dx = np.abs(data[0,0] - data[0,-1])
mi = np.amin(data[1,:])
ma = np.amax(data[1,:])
xc = (np.amax(data[0,:])-np.amin(data[0,:]))/2+np.amin(data[0,:])
return [ma-mi,xc,dx*2,mi]
def getParameters(self):
"""return the fit parameters"""
return np.array(["a","xc","dx","y0"])
def getFitModelStr(self):
"""return a string of the implemented fitting model, i.e. 'linear fit (y=A*x +B)'"""
return "Sigmoidal"
def getResultStr(self):
"""return a special result, i.e. 'Frequency = blabla'"""
return "nothing fitted"
<|fim▁end|> | """return the data that is needed for plotting the fitting result"""
"""0...a, 1...xc, 2...k, 3...y0"""
self.params = [Parameter(v) for v in param]
def f(x): return self.params[0]()/(1+np.exp(-(x-self.params[1]())/self.params[2]()))+self.params[3]()
self.simpleFitAllAxes(f,array,errarray,xmin,xmax, fitAxes)
return self.generateDataFromParameters(f,[np.amin(array[0,:]),np.amax(array[0,:])], np.size(fitAxes)+1, xmin, xmax, fitAxes) |
<|file_name|>pluginFitSigmoidal.py<|end_file_name|><|fim▁begin|>#--------------------------------------------------
# Revision = $Rev: 20 $
# Date = $Date: 2011-08-05 20:42:24 +0200 (Fri, 05 Aug 2011) $
# Author = $Author: stefan $
#--------------------------------------------------
from pluginInterfaces import PluginFit, Parameter,leastsqFit
import numpy as np
class PluginFitThreeBodyBeta(PluginFit):
def __init__(self):
pass
def fit(self,array,errarray,param,xmin=0,xmax=0, fitAxes=[]):
"""return the data that is needed for plotting the fitting result"""
"""0...a, 1...xc, 2...k, 3...y0"""
self.params = [Parameter(v) for v in param]
def f(x): <|fim_middle|>
self.simpleFitAllAxes(f,array,errarray,xmin,xmax, fitAxes)
return self.generateDataFromParameters(f,[np.amin(array[0,:]),np.amax(array[0,:])], np.size(fitAxes)+1, xmin, xmax, fitAxes)
def getInitialParameters(self,data):
"""find the best initial values and return them"""
dx = np.abs(data[0,0] - data[0,-1])
mi = np.amin(data[1,:])
ma = np.amax(data[1,:])
xc = (np.amax(data[0,:])-np.amin(data[0,:]))/2+np.amin(data[0,:])
return [ma-mi,xc,dx*2,mi]
def getParameters(self):
"""return the fit parameters"""
return np.array(["a","xc","dx","y0"])
def getFitModelStr(self):
"""return a string of the implemented fitting model, i.e. 'linear fit (y=A*x +B)'"""
return "Sigmoidal"
def getResultStr(self):
"""return a special result, i.e. 'Frequency = blabla'"""
return "nothing fitted"
<|fim▁end|> | return self.params[0]()/(1+np.exp(-(x-self.params[1]())/self.params[2]()))+self.params[3]() |
<|file_name|>pluginFitSigmoidal.py<|end_file_name|><|fim▁begin|>#--------------------------------------------------
# Revision = $Rev: 20 $
# Date = $Date: 2011-08-05 20:42:24 +0200 (Fri, 05 Aug 2011) $
# Author = $Author: stefan $
#--------------------------------------------------
from pluginInterfaces import PluginFit, Parameter,leastsqFit
import numpy as np
class PluginFitThreeBodyBeta(PluginFit):
def __init__(self):
pass
def fit(self,array,errarray,param,xmin=0,xmax=0, fitAxes=[]):
"""return the data that is needed for plotting the fitting result"""
"""0...a, 1...xc, 2...k, 3...y0"""
self.params = [Parameter(v) for v in param]
def f(x): return self.params[0]()/(1+np.exp(-(x-self.params[1]())/self.params[2]()))+self.params[3]()
self.simpleFitAllAxes(f,array,errarray,xmin,xmax, fitAxes)
return self.generateDataFromParameters(f,[np.amin(array[0,:]),np.amax(array[0,:])], np.size(fitAxes)+1, xmin, xmax, fitAxes)
def getInitialParameters(self,data):
<|fim_middle|>
def getParameters(self):
"""return the fit parameters"""
return np.array(["a","xc","dx","y0"])
def getFitModelStr(self):
"""return a string of the implemented fitting model, i.e. 'linear fit (y=A*x +B)'"""
return "Sigmoidal"
def getResultStr(self):
"""return a special result, i.e. 'Frequency = blabla'"""
return "nothing fitted"
<|fim▁end|> | """find the best initial values and return them"""
dx = np.abs(data[0,0] - data[0,-1])
mi = np.amin(data[1,:])
ma = np.amax(data[1,:])
xc = (np.amax(data[0,:])-np.amin(data[0,:]))/2+np.amin(data[0,:])
return [ma-mi,xc,dx*2,mi] |
<|file_name|>pluginFitSigmoidal.py<|end_file_name|><|fim▁begin|>#--------------------------------------------------
# Revision = $Rev: 20 $
# Date = $Date: 2011-08-05 20:42:24 +0200 (Fri, 05 Aug 2011) $
# Author = $Author: stefan $
#--------------------------------------------------
from pluginInterfaces import PluginFit, Parameter,leastsqFit
import numpy as np
class PluginFitThreeBodyBeta(PluginFit):
def __init__(self):
pass
def fit(self,array,errarray,param,xmin=0,xmax=0, fitAxes=[]):
"""return the data that is needed for plotting the fitting result"""
"""0...a, 1...xc, 2...k, 3...y0"""
self.params = [Parameter(v) for v in param]
def f(x): return self.params[0]()/(1+np.exp(-(x-self.params[1]())/self.params[2]()))+self.params[3]()
self.simpleFitAllAxes(f,array,errarray,xmin,xmax, fitAxes)
return self.generateDataFromParameters(f,[np.amin(array[0,:]),np.amax(array[0,:])], np.size(fitAxes)+1, xmin, xmax, fitAxes)
def getInitialParameters(self,data):
"""find the best initial values and return them"""
dx = np.abs(data[0,0] - data[0,-1])
mi = np.amin(data[1,:])
ma = np.amax(data[1,:])
xc = (np.amax(data[0,:])-np.amin(data[0,:]))/2+np.amin(data[0,:])
return [ma-mi,xc,dx*2,mi]
def getParameters(self):
<|fim_middle|>
def getFitModelStr(self):
"""return a string of the implemented fitting model, i.e. 'linear fit (y=A*x +B)'"""
return "Sigmoidal"
def getResultStr(self):
"""return a special result, i.e. 'Frequency = blabla'"""
return "nothing fitted"
<|fim▁end|> | """return the fit parameters"""
return np.array(["a","xc","dx","y0"]) |
<|file_name|>pluginFitSigmoidal.py<|end_file_name|><|fim▁begin|>#--------------------------------------------------
# Revision = $Rev: 20 $
# Date = $Date: 2011-08-05 20:42:24 +0200 (Fri, 05 Aug 2011) $
# Author = $Author: stefan $
#--------------------------------------------------
from pluginInterfaces import PluginFit, Parameter,leastsqFit
import numpy as np
class PluginFitThreeBodyBeta(PluginFit):
def __init__(self):
pass
def fit(self,array,errarray,param,xmin=0,xmax=0, fitAxes=[]):
"""return the data that is needed for plotting the fitting result"""
"""0...a, 1...xc, 2...k, 3...y0"""
self.params = [Parameter(v) for v in param]
def f(x): return self.params[0]()/(1+np.exp(-(x-self.params[1]())/self.params[2]()))+self.params[3]()
self.simpleFitAllAxes(f,array,errarray,xmin,xmax, fitAxes)
return self.generateDataFromParameters(f,[np.amin(array[0,:]),np.amax(array[0,:])], np.size(fitAxes)+1, xmin, xmax, fitAxes)
def getInitialParameters(self,data):
"""find the best initial values and return them"""
dx = np.abs(data[0,0] - data[0,-1])
mi = np.amin(data[1,:])
ma = np.amax(data[1,:])
xc = (np.amax(data[0,:])-np.amin(data[0,:]))/2+np.amin(data[0,:])
return [ma-mi,xc,dx*2,mi]
def getParameters(self):
"""return the fit parameters"""
return np.array(["a","xc","dx","y0"])
def getFitModelStr(self):
<|fim_middle|>
def getResultStr(self):
"""return a special result, i.e. 'Frequency = blabla'"""
return "nothing fitted"
<|fim▁end|> | """return a string of the implemented fitting model, i.e. 'linear fit (y=A*x +B)'"""
return "Sigmoidal" |
<|file_name|>pluginFitSigmoidal.py<|end_file_name|><|fim▁begin|>#--------------------------------------------------
# Revision = $Rev: 20 $
# Date = $Date: 2011-08-05 20:42:24 +0200 (Fri, 05 Aug 2011) $
# Author = $Author: stefan $
#--------------------------------------------------
from pluginInterfaces import PluginFit, Parameter,leastsqFit
import numpy as np
class PluginFitThreeBodyBeta(PluginFit):
def __init__(self):
pass
def fit(self,array,errarray,param,xmin=0,xmax=0, fitAxes=[]):
"""return the data that is needed for plotting the fitting result"""
"""0...a, 1...xc, 2...k, 3...y0"""
self.params = [Parameter(v) for v in param]
def f(x): return self.params[0]()/(1+np.exp(-(x-self.params[1]())/self.params[2]()))+self.params[3]()
self.simpleFitAllAxes(f,array,errarray,xmin,xmax, fitAxes)
return self.generateDataFromParameters(f,[np.amin(array[0,:]),np.amax(array[0,:])], np.size(fitAxes)+1, xmin, xmax, fitAxes)
def getInitialParameters(self,data):
"""find the best initial values and return them"""
dx = np.abs(data[0,0] - data[0,-1])
mi = np.amin(data[1,:])
ma = np.amax(data[1,:])
xc = (np.amax(data[0,:])-np.amin(data[0,:]))/2+np.amin(data[0,:])
return [ma-mi,xc,dx*2,mi]
def getParameters(self):
"""return the fit parameters"""
return np.array(["a","xc","dx","y0"])
def getFitModelStr(self):
"""return a string of the implemented fitting model, i.e. 'linear fit (y=A*x +B)'"""
return "Sigmoidal"
def getResultStr(self):
<|fim_middle|>
<|fim▁end|> | """return a special result, i.e. 'Frequency = blabla'"""
return "nothing fitted" |
<|file_name|>pluginFitSigmoidal.py<|end_file_name|><|fim▁begin|>#--------------------------------------------------
# Revision = $Rev: 20 $
# Date = $Date: 2011-08-05 20:42:24 +0200 (Fri, 05 Aug 2011) $
# Author = $Author: stefan $
#--------------------------------------------------
from pluginInterfaces import PluginFit, Parameter,leastsqFit
import numpy as np
class PluginFitThreeBodyBeta(PluginFit):
def <|fim_middle|>(self):
pass
def fit(self,array,errarray,param,xmin=0,xmax=0, fitAxes=[]):
"""return the data that is needed for plotting the fitting result"""
"""0...a, 1...xc, 2...k, 3...y0"""
self.params = [Parameter(v) for v in param]
def f(x): return self.params[0]()/(1+np.exp(-(x-self.params[1]())/self.params[2]()))+self.params[3]()
self.simpleFitAllAxes(f,array,errarray,xmin,xmax, fitAxes)
return self.generateDataFromParameters(f,[np.amin(array[0,:]),np.amax(array[0,:])], np.size(fitAxes)+1, xmin, xmax, fitAxes)
def getInitialParameters(self,data):
"""find the best initial values and return them"""
dx = np.abs(data[0,0] - data[0,-1])
mi = np.amin(data[1,:])
ma = np.amax(data[1,:])
xc = (np.amax(data[0,:])-np.amin(data[0,:]))/2+np.amin(data[0,:])
return [ma-mi,xc,dx*2,mi]
def getParameters(self):
"""return the fit parameters"""
return np.array(["a","xc","dx","y0"])
def getFitModelStr(self):
"""return a string of the implemented fitting model, i.e. 'linear fit (y=A*x +B)'"""
return "Sigmoidal"
def getResultStr(self):
"""return a special result, i.e. 'Frequency = blabla'"""
return "nothing fitted"
<|fim▁end|> | __init__ |
<|file_name|>pluginFitSigmoidal.py<|end_file_name|><|fim▁begin|>#--------------------------------------------------
# Revision = $Rev: 20 $
# Date = $Date: 2011-08-05 20:42:24 +0200 (Fri, 05 Aug 2011) $
# Author = $Author: stefan $
#--------------------------------------------------
from pluginInterfaces import PluginFit, Parameter,leastsqFit
import numpy as np
class PluginFitThreeBodyBeta(PluginFit):
def __init__(self):
pass
def <|fim_middle|>(self,array,errarray,param,xmin=0,xmax=0, fitAxes=[]):
"""return the data that is needed for plotting the fitting result"""
"""0...a, 1...xc, 2...k, 3...y0"""
self.params = [Parameter(v) for v in param]
def f(x): return self.params[0]()/(1+np.exp(-(x-self.params[1]())/self.params[2]()))+self.params[3]()
self.simpleFitAllAxes(f,array,errarray,xmin,xmax, fitAxes)
return self.generateDataFromParameters(f,[np.amin(array[0,:]),np.amax(array[0,:])], np.size(fitAxes)+1, xmin, xmax, fitAxes)
def getInitialParameters(self,data):
"""find the best initial values and return them"""
dx = np.abs(data[0,0] - data[0,-1])
mi = np.amin(data[1,:])
ma = np.amax(data[1,:])
xc = (np.amax(data[0,:])-np.amin(data[0,:]))/2+np.amin(data[0,:])
return [ma-mi,xc,dx*2,mi]
def getParameters(self):
"""return the fit parameters"""
return np.array(["a","xc","dx","y0"])
def getFitModelStr(self):
"""return a string of the implemented fitting model, i.e. 'linear fit (y=A*x +B)'"""
return "Sigmoidal"
def getResultStr(self):
"""return a special result, i.e. 'Frequency = blabla'"""
return "nothing fitted"
<|fim▁end|> | fit |
<|file_name|>pluginFitSigmoidal.py<|end_file_name|><|fim▁begin|>#--------------------------------------------------
# Revision = $Rev: 20 $
# Date = $Date: 2011-08-05 20:42:24 +0200 (Fri, 05 Aug 2011) $
# Author = $Author: stefan $
#--------------------------------------------------
from pluginInterfaces import PluginFit, Parameter,leastsqFit
import numpy as np
class PluginFitThreeBodyBeta(PluginFit):
def __init__(self):
pass
def fit(self,array,errarray,param,xmin=0,xmax=0, fitAxes=[]):
"""return the data that is needed for plotting the fitting result"""
"""0...a, 1...xc, 2...k, 3...y0"""
self.params = [Parameter(v) for v in param]
def <|fim_middle|>(x): return self.params[0]()/(1+np.exp(-(x-self.params[1]())/self.params[2]()))+self.params[3]()
self.simpleFitAllAxes(f,array,errarray,xmin,xmax, fitAxes)
return self.generateDataFromParameters(f,[np.amin(array[0,:]),np.amax(array[0,:])], np.size(fitAxes)+1, xmin, xmax, fitAxes)
def getInitialParameters(self,data):
"""find the best initial values and return them"""
dx = np.abs(data[0,0] - data[0,-1])
mi = np.amin(data[1,:])
ma = np.amax(data[1,:])
xc = (np.amax(data[0,:])-np.amin(data[0,:]))/2+np.amin(data[0,:])
return [ma-mi,xc,dx*2,mi]
def getParameters(self):
"""return the fit parameters"""
return np.array(["a","xc","dx","y0"])
def getFitModelStr(self):
"""return a string of the implemented fitting model, i.e. 'linear fit (y=A*x +B)'"""
return "Sigmoidal"
def getResultStr(self):
"""return a special result, i.e. 'Frequency = blabla'"""
return "nothing fitted"
<|fim▁end|> | f |
<|file_name|>pluginFitSigmoidal.py<|end_file_name|><|fim▁begin|>#--------------------------------------------------
# Revision = $Rev: 20 $
# Date = $Date: 2011-08-05 20:42:24 +0200 (Fri, 05 Aug 2011) $
# Author = $Author: stefan $
#--------------------------------------------------
from pluginInterfaces import PluginFit, Parameter,leastsqFit
import numpy as np
class PluginFitThreeBodyBeta(PluginFit):
def __init__(self):
pass
def fit(self,array,errarray,param,xmin=0,xmax=0, fitAxes=[]):
"""return the data that is needed for plotting the fitting result"""
"""0...a, 1...xc, 2...k, 3...y0"""
self.params = [Parameter(v) for v in param]
def f(x): return self.params[0]()/(1+np.exp(-(x-self.params[1]())/self.params[2]()))+self.params[3]()
self.simpleFitAllAxes(f,array,errarray,xmin,xmax, fitAxes)
return self.generateDataFromParameters(f,[np.amin(array[0,:]),np.amax(array[0,:])], np.size(fitAxes)+1, xmin, xmax, fitAxes)
def <|fim_middle|>(self,data):
"""find the best initial values and return them"""
dx = np.abs(data[0,0] - data[0,-1])
mi = np.amin(data[1,:])
ma = np.amax(data[1,:])
xc = (np.amax(data[0,:])-np.amin(data[0,:]))/2+np.amin(data[0,:])
return [ma-mi,xc,dx*2,mi]
def getParameters(self):
"""return the fit parameters"""
return np.array(["a","xc","dx","y0"])
def getFitModelStr(self):
"""return a string of the implemented fitting model, i.e. 'linear fit (y=A*x +B)'"""
return "Sigmoidal"
def getResultStr(self):
"""return a special result, i.e. 'Frequency = blabla'"""
return "nothing fitted"
<|fim▁end|> | getInitialParameters |
<|file_name|>pluginFitSigmoidal.py<|end_file_name|><|fim▁begin|>#--------------------------------------------------
# Revision = $Rev: 20 $
# Date = $Date: 2011-08-05 20:42:24 +0200 (Fri, 05 Aug 2011) $
# Author = $Author: stefan $
#--------------------------------------------------
from pluginInterfaces import PluginFit, Parameter,leastsqFit
import numpy as np
class PluginFitThreeBodyBeta(PluginFit):
def __init__(self):
pass
def fit(self,array,errarray,param,xmin=0,xmax=0, fitAxes=[]):
"""return the data that is needed for plotting the fitting result"""
"""0...a, 1...xc, 2...k, 3...y0"""
self.params = [Parameter(v) for v in param]
def f(x): return self.params[0]()/(1+np.exp(-(x-self.params[1]())/self.params[2]()))+self.params[3]()
self.simpleFitAllAxes(f,array,errarray,xmin,xmax, fitAxes)
return self.generateDataFromParameters(f,[np.amin(array[0,:]),np.amax(array[0,:])], np.size(fitAxes)+1, xmin, xmax, fitAxes)
def getInitialParameters(self,data):
"""find the best initial values and return them"""
dx = np.abs(data[0,0] - data[0,-1])
mi = np.amin(data[1,:])
ma = np.amax(data[1,:])
xc = (np.amax(data[0,:])-np.amin(data[0,:]))/2+np.amin(data[0,:])
return [ma-mi,xc,dx*2,mi]
def <|fim_middle|>(self):
"""return the fit parameters"""
return np.array(["a","xc","dx","y0"])
def getFitModelStr(self):
"""return a string of the implemented fitting model, i.e. 'linear fit (y=A*x +B)'"""
return "Sigmoidal"
def getResultStr(self):
"""return a special result, i.e. 'Frequency = blabla'"""
return "nothing fitted"
<|fim▁end|> | getParameters |
<|file_name|>pluginFitSigmoidal.py<|end_file_name|><|fim▁begin|>#--------------------------------------------------
# Revision = $Rev: 20 $
# Date = $Date: 2011-08-05 20:42:24 +0200 (Fri, 05 Aug 2011) $
# Author = $Author: stefan $
#--------------------------------------------------
from pluginInterfaces import PluginFit, Parameter,leastsqFit
import numpy as np
class PluginFitThreeBodyBeta(PluginFit):
def __init__(self):
pass
def fit(self,array,errarray,param,xmin=0,xmax=0, fitAxes=[]):
"""return the data that is needed for plotting the fitting result"""
"""0...a, 1...xc, 2...k, 3...y0"""
self.params = [Parameter(v) for v in param]
def f(x): return self.params[0]()/(1+np.exp(-(x-self.params[1]())/self.params[2]()))+self.params[3]()
self.simpleFitAllAxes(f,array,errarray,xmin,xmax, fitAxes)
return self.generateDataFromParameters(f,[np.amin(array[0,:]),np.amax(array[0,:])], np.size(fitAxes)+1, xmin, xmax, fitAxes)
def getInitialParameters(self,data):
"""find the best initial values and return them"""
dx = np.abs(data[0,0] - data[0,-1])
mi = np.amin(data[1,:])
ma = np.amax(data[1,:])
xc = (np.amax(data[0,:])-np.amin(data[0,:]))/2+np.amin(data[0,:])
return [ma-mi,xc,dx*2,mi]
def getParameters(self):
"""return the fit parameters"""
return np.array(["a","xc","dx","y0"])
def <|fim_middle|>(self):
"""return a string of the implemented fitting model, i.e. 'linear fit (y=A*x +B)'"""
return "Sigmoidal"
def getResultStr(self):
"""return a special result, i.e. 'Frequency = blabla'"""
return "nothing fitted"
<|fim▁end|> | getFitModelStr |
<|file_name|>pluginFitSigmoidal.py<|end_file_name|><|fim▁begin|>#--------------------------------------------------
# Revision = $Rev: 20 $
# Date = $Date: 2011-08-05 20:42:24 +0200 (Fri, 05 Aug 2011) $
# Author = $Author: stefan $
#--------------------------------------------------
from pluginInterfaces import PluginFit, Parameter,leastsqFit
import numpy as np
class PluginFitThreeBodyBeta(PluginFit):
def __init__(self):
pass
def fit(self,array,errarray,param,xmin=0,xmax=0, fitAxes=[]):
"""return the data that is needed for plotting the fitting result"""
"""0...a, 1...xc, 2...k, 3...y0"""
self.params = [Parameter(v) for v in param]
def f(x): return self.params[0]()/(1+np.exp(-(x-self.params[1]())/self.params[2]()))+self.params[3]()
self.simpleFitAllAxes(f,array,errarray,xmin,xmax, fitAxes)
return self.generateDataFromParameters(f,[np.amin(array[0,:]),np.amax(array[0,:])], np.size(fitAxes)+1, xmin, xmax, fitAxes)
def getInitialParameters(self,data):
"""find the best initial values and return them"""
dx = np.abs(data[0,0] - data[0,-1])
mi = np.amin(data[1,:])
ma = np.amax(data[1,:])
xc = (np.amax(data[0,:])-np.amin(data[0,:]))/2+np.amin(data[0,:])
return [ma-mi,xc,dx*2,mi]
def getParameters(self):
"""return the fit parameters"""
return np.array(["a","xc","dx","y0"])
def getFitModelStr(self):
"""return a string of the implemented fitting model, i.e. 'linear fit (y=A*x +B)'"""
return "Sigmoidal"
def <|fim_middle|>(self):
"""return a special result, i.e. 'Frequency = blabla'"""
return "nothing fitted"
<|fim▁end|> | getResultStr |
<|file_name|>csrf_test.py<|end_file_name|><|fim▁begin|>"""Tests for the CSRF helper."""
import unittest
import mock
import webapp2
import webtest
from ctc.helpers import csrf
from ctc.testing import testutil
MOCKED_TIME = 123
# Tests don't need docstrings, so pylint: disable=C0111
# Tests can test protected members, so pylint: disable=W0212
class CsrfTests(testutil.CtcTestCase):
# Helpers
class TestHandler(csrf.CsrfHandler):
"""A handler for testing whether or not requests are CSRF protected."""
def get(self):
self.response.write('CSRF Token:%s' % self.csrf_token)
def post(self):
pass
def put(self):
pass
def delete(self):
pass
def setUp(self):
super(CsrfTests, self).setUp()
# The CSRF library uses the time, so we mock it out.
self.time_mock = mock.Mock()
csrf.time = self.time_mock
self.time_mock.time = mock.Mock(return_value=MOCKED_TIME)
# The handler tests need a WSGIApplication.
app = webapp2.WSGIApplication([('/', self.TestHandler)])
self.testapp = webtest.TestApp(app)
def test_get_secret_key(self):
first_key = csrf._get_secret_key()
self.assertEqual(len(first_key), 32)
second_key = csrf._get_secret_key()
self.assertEqual(first_key, second_key)
def test_tokens_are_equal(self):
# It should fail if the tokens aren't equal length.
self.assertFalse(csrf._tokens_are_equal('a', 'ab'))
# It should fail if the tokens are different.
self.assertFalse(csrf._tokens_are_equal('abcde', 'abcdf'))
# It should succeed if the tokens are the same.
self.assertTrue(csrf._tokens_are_equal('abcde', 'abcde'))
# Make Token
def test_make_token_includes_time(self):
self.login()
# It should get the current time.
token1 = csrf.make_token()
self.assertEqual(token1.split()[-1], str(MOCKED_TIME))
# It should use the provided time.
token2 = csrf.make_token(token_time='456')
self.assertEqual(token2.split()[-1], '456')
# Different time should cause the digest to be different.
self.assertNotEqual(token1.split()[0], token2.split()[0])
token3 = csrf.make_token(token_time='456')
self.assertEqual(token2, token3)
def test_make_token_requires_login(self):
token1 = csrf.make_token()
self.assertIsNone(token1)
self.login()
token2 = csrf.make_token()
self.assertIsNotNone(token2)
def test_make_token_includes_path(self):
self.login()
# It should get the current path.
self.testbed.setup_env(PATH_INFO='/action/1', overwrite=True)
token1 = csrf.make_token(token_time='123')
self.testbed.setup_env(PATH_INFO='/action/23', overwrite=True)
token2 = csrf.make_token(token_time='123')
token3 = csrf.make_token(token_time='123')
self.assertNotEqual(token1, token2)
self.assertEqual(token2, token3)
# It should let the client pass in a path.
token4 = csrf.make_token(path='/action/4', token_time='123')
token5 = csrf.make_token(path='/action/56', token_time='123')
token6 = csrf.make_token(path='/action/56', token_time='123')
self.assertNotEqual(token4, token5)
self.assertEqual(token5, token6)
# Token Is Valid
def test_token_is_valid(self):
self.login()
# Token is required.
self.assertFalse(csrf.token_is_valid(None))
# Token needs to have a timestamp on it.
self.assertFalse(csrf.token_is_valid('hello'))
# The timestamp needs to be within the current date range.
self.time_mock.time = mock.Mock(return_value=9999999999999)
self.assertFalse(csrf.token_is_valid('hello 123'))
# The user needs to be logged in.
token = csrf.make_token()<|fim▁hole|> self.login()
# Modifying the token should break everything.
modified_token = '0' + token[1:]
if token == modified_token:
modified_token = '1' + token[1:]
self.assertFalse(csrf.token_is_valid(modified_token))
# The original token that we got should work.
self.assertTrue(csrf.token_is_valid(token))
def test_get_has_csrf_token(self):
self.login()
response = self.testapp.get('/', status=200).body
self.assertIn('CSRF Token:', response)
self.assertEqual(response.split(':')[-1], csrf.make_token())
def test_mutators_require_csrf_token(self):
self.login()
self.testapp.put('/', status=403)
self.testapp.post('/', status=403)
self.testapp.delete('/', status=403)
csrf_param = 'csrf_token=' + csrf.make_token(path='/')
self.testapp.put('/', params=csrf_param, status=200)
self.testapp.post('/', params=csrf_param, status=200)
# Though the spec allows DELETE to have a body, it tends to be ignored
# by servers (http://stackoverflow.com/questions/299628), and webapp2
# ignores it as well, so we have to put the params in the URL.
self.testapp.delete('/?' + csrf_param, status=200)
if __name__ == '__main__':
unittest.main()<|fim▁end|> | self.logout()
self.assertFalse(csrf.token_is_valid(token)) |
<|file_name|>csrf_test.py<|end_file_name|><|fim▁begin|>"""Tests for the CSRF helper."""
import unittest
import mock
import webapp2
import webtest
from ctc.helpers import csrf
from ctc.testing import testutil
MOCKED_TIME = 123
# Tests don't need docstrings, so pylint: disable=C0111
# Tests can test protected members, so pylint: disable=W0212
class CsrfTests(testutil.CtcTestCase):
# Helpers
<|fim_middle|>
if __name__ == '__main__':
unittest.main()
<|fim▁end|> | class TestHandler(csrf.CsrfHandler):
"""A handler for testing whether or not requests are CSRF protected."""
def get(self):
self.response.write('CSRF Token:%s' % self.csrf_token)
def post(self):
pass
def put(self):
pass
def delete(self):
pass
def setUp(self):
super(CsrfTests, self).setUp()
# The CSRF library uses the time, so we mock it out.
self.time_mock = mock.Mock()
csrf.time = self.time_mock
self.time_mock.time = mock.Mock(return_value=MOCKED_TIME)
# The handler tests need a WSGIApplication.
app = webapp2.WSGIApplication([('/', self.TestHandler)])
self.testapp = webtest.TestApp(app)
def test_get_secret_key(self):
first_key = csrf._get_secret_key()
self.assertEqual(len(first_key), 32)
second_key = csrf._get_secret_key()
self.assertEqual(first_key, second_key)
def test_tokens_are_equal(self):
# It should fail if the tokens aren't equal length.
self.assertFalse(csrf._tokens_are_equal('a', 'ab'))
# It should fail if the tokens are different.
self.assertFalse(csrf._tokens_are_equal('abcde', 'abcdf'))
# It should succeed if the tokens are the same.
self.assertTrue(csrf._tokens_are_equal('abcde', 'abcde'))
# Make Token
def test_make_token_includes_time(self):
self.login()
# It should get the current time.
token1 = csrf.make_token()
self.assertEqual(token1.split()[-1], str(MOCKED_TIME))
# It should use the provided time.
token2 = csrf.make_token(token_time='456')
self.assertEqual(token2.split()[-1], '456')
# Different time should cause the digest to be different.
self.assertNotEqual(token1.split()[0], token2.split()[0])
token3 = csrf.make_token(token_time='456')
self.assertEqual(token2, token3)
def test_make_token_requires_login(self):
token1 = csrf.make_token()
self.assertIsNone(token1)
self.login()
token2 = csrf.make_token()
self.assertIsNotNone(token2)
def test_make_token_includes_path(self):
self.login()
# It should get the current path.
self.testbed.setup_env(PATH_INFO='/action/1', overwrite=True)
token1 = csrf.make_token(token_time='123')
self.testbed.setup_env(PATH_INFO='/action/23', overwrite=True)
token2 = csrf.make_token(token_time='123')
token3 = csrf.make_token(token_time='123')
self.assertNotEqual(token1, token2)
self.assertEqual(token2, token3)
# It should let the client pass in a path.
token4 = csrf.make_token(path='/action/4', token_time='123')
token5 = csrf.make_token(path='/action/56', token_time='123')
token6 = csrf.make_token(path='/action/56', token_time='123')
self.assertNotEqual(token4, token5)
self.assertEqual(token5, token6)
# Token Is Valid
def test_token_is_valid(self):
self.login()
# Token is required.
self.assertFalse(csrf.token_is_valid(None))
# Token needs to have a timestamp on it.
self.assertFalse(csrf.token_is_valid('hello'))
# The timestamp needs to be within the current date range.
self.time_mock.time = mock.Mock(return_value=9999999999999)
self.assertFalse(csrf.token_is_valid('hello 123'))
# The user needs to be logged in.
token = csrf.make_token()
self.logout()
self.assertFalse(csrf.token_is_valid(token))
self.login()
# Modifying the token should break everything.
modified_token = '0' + token[1:]
if token == modified_token:
modified_token = '1' + token[1:]
self.assertFalse(csrf.token_is_valid(modified_token))
# The original token that we got should work.
self.assertTrue(csrf.token_is_valid(token))
def test_get_has_csrf_token(self):
self.login()
response = self.testapp.get('/', status=200).body
self.assertIn('CSRF Token:', response)
self.assertEqual(response.split(':')[-1], csrf.make_token())
def test_mutators_require_csrf_token(self):
self.login()
self.testapp.put('/', status=403)
self.testapp.post('/', status=403)
self.testapp.delete('/', status=403)
csrf_param = 'csrf_token=' + csrf.make_token(path='/')
self.testapp.put('/', params=csrf_param, status=200)
self.testapp.post('/', params=csrf_param, status=200)
# Though the spec allows DELETE to have a body, it tends to be ignored
# by servers (http://stackoverflow.com/questions/299628), and webapp2
# ignores it as well, so we have to put the params in the URL.
self.testapp.delete('/?' + csrf_param, status=200) |
<|file_name|>csrf_test.py<|end_file_name|><|fim▁begin|>"""Tests for the CSRF helper."""
import unittest
import mock
import webapp2
import webtest
from ctc.helpers import csrf
from ctc.testing import testutil
MOCKED_TIME = 123
# Tests don't need docstrings, so pylint: disable=C0111
# Tests can test protected members, so pylint: disable=W0212
class CsrfTests(testutil.CtcTestCase):
# Helpers
class TestHandler(csrf.CsrfHandler):
<|fim_middle|>
def setUp(self):
super(CsrfTests, self).setUp()
# The CSRF library uses the time, so we mock it out.
self.time_mock = mock.Mock()
csrf.time = self.time_mock
self.time_mock.time = mock.Mock(return_value=MOCKED_TIME)
# The handler tests need a WSGIApplication.
app = webapp2.WSGIApplication([('/', self.TestHandler)])
self.testapp = webtest.TestApp(app)
def test_get_secret_key(self):
first_key = csrf._get_secret_key()
self.assertEqual(len(first_key), 32)
second_key = csrf._get_secret_key()
self.assertEqual(first_key, second_key)
def test_tokens_are_equal(self):
# It should fail if the tokens aren't equal length.
self.assertFalse(csrf._tokens_are_equal('a', 'ab'))
# It should fail if the tokens are different.
self.assertFalse(csrf._tokens_are_equal('abcde', 'abcdf'))
# It should succeed if the tokens are the same.
self.assertTrue(csrf._tokens_are_equal('abcde', 'abcde'))
# Make Token
def test_make_token_includes_time(self):
self.login()
# It should get the current time.
token1 = csrf.make_token()
self.assertEqual(token1.split()[-1], str(MOCKED_TIME))
# It should use the provided time.
token2 = csrf.make_token(token_time='456')
self.assertEqual(token2.split()[-1], '456')
# Different time should cause the digest to be different.
self.assertNotEqual(token1.split()[0], token2.split()[0])
token3 = csrf.make_token(token_time='456')
self.assertEqual(token2, token3)
def test_make_token_requires_login(self):
token1 = csrf.make_token()
self.assertIsNone(token1)
self.login()
token2 = csrf.make_token()
self.assertIsNotNone(token2)
def test_make_token_includes_path(self):
self.login()
# It should get the current path.
self.testbed.setup_env(PATH_INFO='/action/1', overwrite=True)
token1 = csrf.make_token(token_time='123')
self.testbed.setup_env(PATH_INFO='/action/23', overwrite=True)
token2 = csrf.make_token(token_time='123')
token3 = csrf.make_token(token_time='123')
self.assertNotEqual(token1, token2)
self.assertEqual(token2, token3)
# It should let the client pass in a path.
token4 = csrf.make_token(path='/action/4', token_time='123')
token5 = csrf.make_token(path='/action/56', token_time='123')
token6 = csrf.make_token(path='/action/56', token_time='123')
self.assertNotEqual(token4, token5)
self.assertEqual(token5, token6)
# Token Is Valid
def test_token_is_valid(self):
self.login()
# Token is required.
self.assertFalse(csrf.token_is_valid(None))
# Token needs to have a timestamp on it.
self.assertFalse(csrf.token_is_valid('hello'))
# The timestamp needs to be within the current date range.
self.time_mock.time = mock.Mock(return_value=9999999999999)
self.assertFalse(csrf.token_is_valid('hello 123'))
# The user needs to be logged in.
token = csrf.make_token()
self.logout()
self.assertFalse(csrf.token_is_valid(token))
self.login()
# Modifying the token should break everything.
modified_token = '0' + token[1:]
if token == modified_token:
modified_token = '1' + token[1:]
self.assertFalse(csrf.token_is_valid(modified_token))
# The original token that we got should work.
self.assertTrue(csrf.token_is_valid(token))
def test_get_has_csrf_token(self):
self.login()
response = self.testapp.get('/', status=200).body
self.assertIn('CSRF Token:', response)
self.assertEqual(response.split(':')[-1], csrf.make_token())
def test_mutators_require_csrf_token(self):
self.login()
self.testapp.put('/', status=403)
self.testapp.post('/', status=403)
self.testapp.delete('/', status=403)
csrf_param = 'csrf_token=' + csrf.make_token(path='/')
self.testapp.put('/', params=csrf_param, status=200)
self.testapp.post('/', params=csrf_param, status=200)
# Though the spec allows DELETE to have a body, it tends to be ignored
# by servers (http://stackoverflow.com/questions/299628), and webapp2
# ignores it as well, so we have to put the params in the URL.
self.testapp.delete('/?' + csrf_param, status=200)
if __name__ == '__main__':
unittest.main()
<|fim▁end|> | """A handler for testing whether or not requests are CSRF protected."""
def get(self):
self.response.write('CSRF Token:%s' % self.csrf_token)
def post(self):
pass
def put(self):
pass
def delete(self):
pass |
<|file_name|>csrf_test.py<|end_file_name|><|fim▁begin|>"""Tests for the CSRF helper."""
import unittest
import mock
import webapp2
import webtest
from ctc.helpers import csrf
from ctc.testing import testutil
MOCKED_TIME = 123
# Tests don't need docstrings, so pylint: disable=C0111
# Tests can test protected members, so pylint: disable=W0212
class CsrfTests(testutil.CtcTestCase):
# Helpers
class TestHandler(csrf.CsrfHandler):
"""A handler for testing whether or not requests are CSRF protected."""
def get(self):
<|fim_middle|>
def post(self):
pass
def put(self):
pass
def delete(self):
pass
def setUp(self):
super(CsrfTests, self).setUp()
# The CSRF library uses the time, so we mock it out.
self.time_mock = mock.Mock()
csrf.time = self.time_mock
self.time_mock.time = mock.Mock(return_value=MOCKED_TIME)
# The handler tests need a WSGIApplication.
app = webapp2.WSGIApplication([('/', self.TestHandler)])
self.testapp = webtest.TestApp(app)
def test_get_secret_key(self):
first_key = csrf._get_secret_key()
self.assertEqual(len(first_key), 32)
second_key = csrf._get_secret_key()
self.assertEqual(first_key, second_key)
def test_tokens_are_equal(self):
# It should fail if the tokens aren't equal length.
self.assertFalse(csrf._tokens_are_equal('a', 'ab'))
# It should fail if the tokens are different.
self.assertFalse(csrf._tokens_are_equal('abcde', 'abcdf'))
# It should succeed if the tokens are the same.
self.assertTrue(csrf._tokens_are_equal('abcde', 'abcde'))
# Make Token
def test_make_token_includes_time(self):
self.login()
# It should get the current time.
token1 = csrf.make_token()
self.assertEqual(token1.split()[-1], str(MOCKED_TIME))
# It should use the provided time.
token2 = csrf.make_token(token_time='456')
self.assertEqual(token2.split()[-1], '456')
# Different time should cause the digest to be different.
self.assertNotEqual(token1.split()[0], token2.split()[0])
token3 = csrf.make_token(token_time='456')
self.assertEqual(token2, token3)
def test_make_token_requires_login(self):
token1 = csrf.make_token()
self.assertIsNone(token1)
self.login()
token2 = csrf.make_token()
self.assertIsNotNone(token2)
def test_make_token_includes_path(self):
self.login()
# It should get the current path.
self.testbed.setup_env(PATH_INFO='/action/1', overwrite=True)
token1 = csrf.make_token(token_time='123')
self.testbed.setup_env(PATH_INFO='/action/23', overwrite=True)
token2 = csrf.make_token(token_time='123')
token3 = csrf.make_token(token_time='123')
self.assertNotEqual(token1, token2)
self.assertEqual(token2, token3)
# It should let the client pass in a path.
token4 = csrf.make_token(path='/action/4', token_time='123')
token5 = csrf.make_token(path='/action/56', token_time='123')
token6 = csrf.make_token(path='/action/56', token_time='123')
self.assertNotEqual(token4, token5)
self.assertEqual(token5, token6)
# Token Is Valid
def test_token_is_valid(self):
self.login()
# Token is required.
self.assertFalse(csrf.token_is_valid(None))
# Token needs to have a timestamp on it.
self.assertFalse(csrf.token_is_valid('hello'))
# The timestamp needs to be within the current date range.
self.time_mock.time = mock.Mock(return_value=9999999999999)
self.assertFalse(csrf.token_is_valid('hello 123'))
# The user needs to be logged in.
token = csrf.make_token()
self.logout()
self.assertFalse(csrf.token_is_valid(token))
self.login()
# Modifying the token should break everything.
modified_token = '0' + token[1:]
if token == modified_token:
modified_token = '1' + token[1:]
self.assertFalse(csrf.token_is_valid(modified_token))
# The original token that we got should work.
self.assertTrue(csrf.token_is_valid(token))
def test_get_has_csrf_token(self):
self.login()
response = self.testapp.get('/', status=200).body
self.assertIn('CSRF Token:', response)
self.assertEqual(response.split(':')[-1], csrf.make_token())
def test_mutators_require_csrf_token(self):
self.login()
self.testapp.put('/', status=403)
self.testapp.post('/', status=403)
self.testapp.delete('/', status=403)
csrf_param = 'csrf_token=' + csrf.make_token(path='/')
self.testapp.put('/', params=csrf_param, status=200)
self.testapp.post('/', params=csrf_param, status=200)
# Though the spec allows DELETE to have a body, it tends to be ignored
# by servers (http://stackoverflow.com/questions/299628), and webapp2
# ignores it as well, so we have to put the params in the URL.
self.testapp.delete('/?' + csrf_param, status=200)
if __name__ == '__main__':
unittest.main()
<|fim▁end|> | self.response.write('CSRF Token:%s' % self.csrf_token) |
<|file_name|>csrf_test.py<|end_file_name|><|fim▁begin|>"""Tests for the CSRF helper."""
import unittest
import mock
import webapp2
import webtest
from ctc.helpers import csrf
from ctc.testing import testutil
MOCKED_TIME = 123
# Tests don't need docstrings, so pylint: disable=C0111
# Tests can test protected members, so pylint: disable=W0212
class CsrfTests(testutil.CtcTestCase):
# Helpers
class TestHandler(csrf.CsrfHandler):
"""A handler for testing whether or not requests are CSRF protected."""
def get(self):
self.response.write('CSRF Token:%s' % self.csrf_token)
def post(self):
<|fim_middle|>
def put(self):
pass
def delete(self):
pass
def setUp(self):
super(CsrfTests, self).setUp()
# The CSRF library uses the time, so we mock it out.
self.time_mock = mock.Mock()
csrf.time = self.time_mock
self.time_mock.time = mock.Mock(return_value=MOCKED_TIME)
# The handler tests need a WSGIApplication.
app = webapp2.WSGIApplication([('/', self.TestHandler)])
self.testapp = webtest.TestApp(app)
def test_get_secret_key(self):
first_key = csrf._get_secret_key()
self.assertEqual(len(first_key), 32)
second_key = csrf._get_secret_key()
self.assertEqual(first_key, second_key)
def test_tokens_are_equal(self):
# It should fail if the tokens aren't equal length.
self.assertFalse(csrf._tokens_are_equal('a', 'ab'))
# It should fail if the tokens are different.
self.assertFalse(csrf._tokens_are_equal('abcde', 'abcdf'))
# It should succeed if the tokens are the same.
self.assertTrue(csrf._tokens_are_equal('abcde', 'abcde'))
# Make Token
def test_make_token_includes_time(self):
self.login()
# It should get the current time.
token1 = csrf.make_token()
self.assertEqual(token1.split()[-1], str(MOCKED_TIME))
# It should use the provided time.
token2 = csrf.make_token(token_time='456')
self.assertEqual(token2.split()[-1], '456')
# Different time should cause the digest to be different.
self.assertNotEqual(token1.split()[0], token2.split()[0])
token3 = csrf.make_token(token_time='456')
self.assertEqual(token2, token3)
def test_make_token_requires_login(self):
token1 = csrf.make_token()
self.assertIsNone(token1)
self.login()
token2 = csrf.make_token()
self.assertIsNotNone(token2)
def test_make_token_includes_path(self):
self.login()
# It should get the current path.
self.testbed.setup_env(PATH_INFO='/action/1', overwrite=True)
token1 = csrf.make_token(token_time='123')
self.testbed.setup_env(PATH_INFO='/action/23', overwrite=True)
token2 = csrf.make_token(token_time='123')
token3 = csrf.make_token(token_time='123')
self.assertNotEqual(token1, token2)
self.assertEqual(token2, token3)
# It should let the client pass in a path.
token4 = csrf.make_token(path='/action/4', token_time='123')
token5 = csrf.make_token(path='/action/56', token_time='123')
token6 = csrf.make_token(path='/action/56', token_time='123')
self.assertNotEqual(token4, token5)
self.assertEqual(token5, token6)
# Token Is Valid
def test_token_is_valid(self):
self.login()
# Token is required.
self.assertFalse(csrf.token_is_valid(None))
# Token needs to have a timestamp on it.
self.assertFalse(csrf.token_is_valid('hello'))
# The timestamp needs to be within the current date range.
self.time_mock.time = mock.Mock(return_value=9999999999999)
self.assertFalse(csrf.token_is_valid('hello 123'))
# The user needs to be logged in.
token = csrf.make_token()
self.logout()
self.assertFalse(csrf.token_is_valid(token))
self.login()
# Modifying the token should break everything.
modified_token = '0' + token[1:]
if token == modified_token:
modified_token = '1' + token[1:]
self.assertFalse(csrf.token_is_valid(modified_token))
# The original token that we got should work.
self.assertTrue(csrf.token_is_valid(token))
def test_get_has_csrf_token(self):
self.login()
response = self.testapp.get('/', status=200).body
self.assertIn('CSRF Token:', response)
self.assertEqual(response.split(':')[-1], csrf.make_token())
def test_mutators_require_csrf_token(self):
self.login()
self.testapp.put('/', status=403)
self.testapp.post('/', status=403)
self.testapp.delete('/', status=403)
csrf_param = 'csrf_token=' + csrf.make_token(path='/')
self.testapp.put('/', params=csrf_param, status=200)
self.testapp.post('/', params=csrf_param, status=200)
# Though the spec allows DELETE to have a body, it tends to be ignored
# by servers (http://stackoverflow.com/questions/299628), and webapp2
# ignores it as well, so we have to put the params in the URL.
self.testapp.delete('/?' + csrf_param, status=200)
if __name__ == '__main__':
unittest.main()
<|fim▁end|> | pass |
<|file_name|>csrf_test.py<|end_file_name|><|fim▁begin|>"""Tests for the CSRF helper."""
import unittest
import mock
import webapp2
import webtest
from ctc.helpers import csrf
from ctc.testing import testutil
MOCKED_TIME = 123
# Tests don't need docstrings, so pylint: disable=C0111
# Tests can test protected members, so pylint: disable=W0212
class CsrfTests(testutil.CtcTestCase):
# Helpers
class TestHandler(csrf.CsrfHandler):
"""A handler for testing whether or not requests are CSRF protected."""
def get(self):
self.response.write('CSRF Token:%s' % self.csrf_token)
def post(self):
pass
def put(self):
<|fim_middle|>
def delete(self):
pass
def setUp(self):
super(CsrfTests, self).setUp()
# The CSRF library uses the time, so we mock it out.
self.time_mock = mock.Mock()
csrf.time = self.time_mock
self.time_mock.time = mock.Mock(return_value=MOCKED_TIME)
# The handler tests need a WSGIApplication.
app = webapp2.WSGIApplication([('/', self.TestHandler)])
self.testapp = webtest.TestApp(app)
def test_get_secret_key(self):
first_key = csrf._get_secret_key()
self.assertEqual(len(first_key), 32)
second_key = csrf._get_secret_key()
self.assertEqual(first_key, second_key)
def test_tokens_are_equal(self):
# It should fail if the tokens aren't equal length.
self.assertFalse(csrf._tokens_are_equal('a', 'ab'))
# It should fail if the tokens are different.
self.assertFalse(csrf._tokens_are_equal('abcde', 'abcdf'))
# It should succeed if the tokens are the same.
self.assertTrue(csrf._tokens_are_equal('abcde', 'abcde'))
# Make Token
def test_make_token_includes_time(self):
self.login()
# It should get the current time.
token1 = csrf.make_token()
self.assertEqual(token1.split()[-1], str(MOCKED_TIME))
# It should use the provided time.
token2 = csrf.make_token(token_time='456')
self.assertEqual(token2.split()[-1], '456')
# Different time should cause the digest to be different.
self.assertNotEqual(token1.split()[0], token2.split()[0])
token3 = csrf.make_token(token_time='456')
self.assertEqual(token2, token3)
def test_make_token_requires_login(self):
token1 = csrf.make_token()
self.assertIsNone(token1)
self.login()
token2 = csrf.make_token()
self.assertIsNotNone(token2)
def test_make_token_includes_path(self):
self.login()
# It should get the current path.
self.testbed.setup_env(PATH_INFO='/action/1', overwrite=True)
token1 = csrf.make_token(token_time='123')
self.testbed.setup_env(PATH_INFO='/action/23', overwrite=True)
token2 = csrf.make_token(token_time='123')
token3 = csrf.make_token(token_time='123')
self.assertNotEqual(token1, token2)
self.assertEqual(token2, token3)
# It should let the client pass in a path.
token4 = csrf.make_token(path='/action/4', token_time='123')
token5 = csrf.make_token(path='/action/56', token_time='123')
token6 = csrf.make_token(path='/action/56', token_time='123')
self.assertNotEqual(token4, token5)
self.assertEqual(token5, token6)
# Token Is Valid
def test_token_is_valid(self):
self.login()
# Token is required.
self.assertFalse(csrf.token_is_valid(None))
# Token needs to have a timestamp on it.
self.assertFalse(csrf.token_is_valid('hello'))
# The timestamp needs to be within the current date range.
self.time_mock.time = mock.Mock(return_value=9999999999999)
self.assertFalse(csrf.token_is_valid('hello 123'))
# The user needs to be logged in.
token = csrf.make_token()
self.logout()
self.assertFalse(csrf.token_is_valid(token))
self.login()
# Modifying the token should break everything.
modified_token = '0' + token[1:]
if token == modified_token:
modified_token = '1' + token[1:]
self.assertFalse(csrf.token_is_valid(modified_token))
# The original token that we got should work.
self.assertTrue(csrf.token_is_valid(token))
def test_get_has_csrf_token(self):
self.login()
response = self.testapp.get('/', status=200).body
self.assertIn('CSRF Token:', response)
self.assertEqual(response.split(':')[-1], csrf.make_token())
def test_mutators_require_csrf_token(self):
self.login()
self.testapp.put('/', status=403)
self.testapp.post('/', status=403)
self.testapp.delete('/', status=403)
csrf_param = 'csrf_token=' + csrf.make_token(path='/')
self.testapp.put('/', params=csrf_param, status=200)
self.testapp.post('/', params=csrf_param, status=200)
# Though the spec allows DELETE to have a body, it tends to be ignored
# by servers (http://stackoverflow.com/questions/299628), and webapp2
# ignores it as well, so we have to put the params in the URL.
self.testapp.delete('/?' + csrf_param, status=200)
if __name__ == '__main__':
unittest.main()
<|fim▁end|> | pass |
<|file_name|>csrf_test.py<|end_file_name|><|fim▁begin|>"""Tests for the CSRF helper."""
import unittest
import mock
import webapp2
import webtest
from ctc.helpers import csrf
from ctc.testing import testutil
MOCKED_TIME = 123
# Tests don't need docstrings, so pylint: disable=C0111
# Tests can test protected members, so pylint: disable=W0212
class CsrfTests(testutil.CtcTestCase):
# Helpers
class TestHandler(csrf.CsrfHandler):
"""A handler for testing whether or not requests are CSRF protected."""
def get(self):
self.response.write('CSRF Token:%s' % self.csrf_token)
def post(self):
pass
def put(self):
pass
def delete(self):
<|fim_middle|>
def setUp(self):
super(CsrfTests, self).setUp()
# The CSRF library uses the time, so we mock it out.
self.time_mock = mock.Mock()
csrf.time = self.time_mock
self.time_mock.time = mock.Mock(return_value=MOCKED_TIME)
# The handler tests need a WSGIApplication.
app = webapp2.WSGIApplication([('/', self.TestHandler)])
self.testapp = webtest.TestApp(app)
def test_get_secret_key(self):
first_key = csrf._get_secret_key()
self.assertEqual(len(first_key), 32)
second_key = csrf._get_secret_key()
self.assertEqual(first_key, second_key)
def test_tokens_are_equal(self):
# It should fail if the tokens aren't equal length.
self.assertFalse(csrf._tokens_are_equal('a', 'ab'))
# It should fail if the tokens are different.
self.assertFalse(csrf._tokens_are_equal('abcde', 'abcdf'))
# It should succeed if the tokens are the same.
self.assertTrue(csrf._tokens_are_equal('abcde', 'abcde'))
# Make Token
def test_make_token_includes_time(self):
self.login()
# It should get the current time.
token1 = csrf.make_token()
self.assertEqual(token1.split()[-1], str(MOCKED_TIME))
# It should use the provided time.
token2 = csrf.make_token(token_time='456')
self.assertEqual(token2.split()[-1], '456')
# Different time should cause the digest to be different.
self.assertNotEqual(token1.split()[0], token2.split()[0])
token3 = csrf.make_token(token_time='456')
self.assertEqual(token2, token3)
def test_make_token_requires_login(self):
token1 = csrf.make_token()
self.assertIsNone(token1)
self.login()
token2 = csrf.make_token()
self.assertIsNotNone(token2)
def test_make_token_includes_path(self):
self.login()
# It should get the current path.
self.testbed.setup_env(PATH_INFO='/action/1', overwrite=True)
token1 = csrf.make_token(token_time='123')
self.testbed.setup_env(PATH_INFO='/action/23', overwrite=True)
token2 = csrf.make_token(token_time='123')
token3 = csrf.make_token(token_time='123')
self.assertNotEqual(token1, token2)
self.assertEqual(token2, token3)
# It should let the client pass in a path.
token4 = csrf.make_token(path='/action/4', token_time='123')
token5 = csrf.make_token(path='/action/56', token_time='123')
token6 = csrf.make_token(path='/action/56', token_time='123')
self.assertNotEqual(token4, token5)
self.assertEqual(token5, token6)
# Token Is Valid
def test_token_is_valid(self):
self.login()
# Token is required.
self.assertFalse(csrf.token_is_valid(None))
# Token needs to have a timestamp on it.
self.assertFalse(csrf.token_is_valid('hello'))
# The timestamp needs to be within the current date range.
self.time_mock.time = mock.Mock(return_value=9999999999999)
self.assertFalse(csrf.token_is_valid('hello 123'))
# The user needs to be logged in.
token = csrf.make_token()
self.logout()
self.assertFalse(csrf.token_is_valid(token))
self.login()
# Modifying the token should break everything.
modified_token = '0' + token[1:]
if token == modified_token:
modified_token = '1' + token[1:]
self.assertFalse(csrf.token_is_valid(modified_token))
# The original token that we got should work.
self.assertTrue(csrf.token_is_valid(token))
def test_get_has_csrf_token(self):
self.login()
response = self.testapp.get('/', status=200).body
self.assertIn('CSRF Token:', response)
self.assertEqual(response.split(':')[-1], csrf.make_token())
def test_mutators_require_csrf_token(self):
self.login()
self.testapp.put('/', status=403)
self.testapp.post('/', status=403)
self.testapp.delete('/', status=403)
csrf_param = 'csrf_token=' + csrf.make_token(path='/')
self.testapp.put('/', params=csrf_param, status=200)
self.testapp.post('/', params=csrf_param, status=200)
# Though the spec allows DELETE to have a body, it tends to be ignored
# by servers (http://stackoverflow.com/questions/299628), and webapp2
# ignores it as well, so we have to put the params in the URL.
self.testapp.delete('/?' + csrf_param, status=200)
if __name__ == '__main__':
unittest.main()
<|fim▁end|> | pass |
<|file_name|>csrf_test.py<|end_file_name|><|fim▁begin|>"""Tests for the CSRF helper."""
import unittest
import mock
import webapp2
import webtest
from ctc.helpers import csrf
from ctc.testing import testutil
MOCKED_TIME = 123
# Tests don't need docstrings, so pylint: disable=C0111
# Tests can test protected members, so pylint: disable=W0212
class CsrfTests(testutil.CtcTestCase):
# Helpers
class TestHandler(csrf.CsrfHandler):
"""A handler for testing whether or not requests are CSRF protected."""
def get(self):
self.response.write('CSRF Token:%s' % self.csrf_token)
def post(self):
pass
def put(self):
pass
def delete(self):
pass
def setUp(self):
<|fim_middle|>
def test_get_secret_key(self):
first_key = csrf._get_secret_key()
self.assertEqual(len(first_key), 32)
second_key = csrf._get_secret_key()
self.assertEqual(first_key, second_key)
def test_tokens_are_equal(self):
# It should fail if the tokens aren't equal length.
self.assertFalse(csrf._tokens_are_equal('a', 'ab'))
# It should fail if the tokens are different.
self.assertFalse(csrf._tokens_are_equal('abcde', 'abcdf'))
# It should succeed if the tokens are the same.
self.assertTrue(csrf._tokens_are_equal('abcde', 'abcde'))
# Make Token
def test_make_token_includes_time(self):
self.login()
# It should get the current time.
token1 = csrf.make_token()
self.assertEqual(token1.split()[-1], str(MOCKED_TIME))
# It should use the provided time.
token2 = csrf.make_token(token_time='456')
self.assertEqual(token2.split()[-1], '456')
# Different time should cause the digest to be different.
self.assertNotEqual(token1.split()[0], token2.split()[0])
token3 = csrf.make_token(token_time='456')
self.assertEqual(token2, token3)
def test_make_token_requires_login(self):
token1 = csrf.make_token()
self.assertIsNone(token1)
self.login()
token2 = csrf.make_token()
self.assertIsNotNone(token2)
def test_make_token_includes_path(self):
self.login()
# It should get the current path.
self.testbed.setup_env(PATH_INFO='/action/1', overwrite=True)
token1 = csrf.make_token(token_time='123')
self.testbed.setup_env(PATH_INFO='/action/23', overwrite=True)
token2 = csrf.make_token(token_time='123')
token3 = csrf.make_token(token_time='123')
self.assertNotEqual(token1, token2)
self.assertEqual(token2, token3)
# It should let the client pass in a path.
token4 = csrf.make_token(path='/action/4', token_time='123')
token5 = csrf.make_token(path='/action/56', token_time='123')
token6 = csrf.make_token(path='/action/56', token_time='123')
self.assertNotEqual(token4, token5)
self.assertEqual(token5, token6)
# Token Is Valid
def test_token_is_valid(self):
self.login()
# Token is required.
self.assertFalse(csrf.token_is_valid(None))
# Token needs to have a timestamp on it.
self.assertFalse(csrf.token_is_valid('hello'))
# The timestamp needs to be within the current date range.
self.time_mock.time = mock.Mock(return_value=9999999999999)
self.assertFalse(csrf.token_is_valid('hello 123'))
# The user needs to be logged in.
token = csrf.make_token()
self.logout()
self.assertFalse(csrf.token_is_valid(token))
self.login()
# Modifying the token should break everything.
modified_token = '0' + token[1:]
if token == modified_token:
modified_token = '1' + token[1:]
self.assertFalse(csrf.token_is_valid(modified_token))
# The original token that we got should work.
self.assertTrue(csrf.token_is_valid(token))
def test_get_has_csrf_token(self):
self.login()
response = self.testapp.get('/', status=200).body
self.assertIn('CSRF Token:', response)
self.assertEqual(response.split(':')[-1], csrf.make_token())
def test_mutators_require_csrf_token(self):
self.login()
self.testapp.put('/', status=403)
self.testapp.post('/', status=403)
self.testapp.delete('/', status=403)
csrf_param = 'csrf_token=' + csrf.make_token(path='/')
self.testapp.put('/', params=csrf_param, status=200)
self.testapp.post('/', params=csrf_param, status=200)
# Though the spec allows DELETE to have a body, it tends to be ignored
# by servers (http://stackoverflow.com/questions/299628), and webapp2
# ignores it as well, so we have to put the params in the URL.
self.testapp.delete('/?' + csrf_param, status=200)
if __name__ == '__main__':
unittest.main()
<|fim▁end|> | super(CsrfTests, self).setUp()
# The CSRF library uses the time, so we mock it out.
self.time_mock = mock.Mock()
csrf.time = self.time_mock
self.time_mock.time = mock.Mock(return_value=MOCKED_TIME)
# The handler tests need a WSGIApplication.
app = webapp2.WSGIApplication([('/', self.TestHandler)])
self.testapp = webtest.TestApp(app) |
<|file_name|>csrf_test.py<|end_file_name|><|fim▁begin|>"""Tests for the CSRF helper."""
import unittest
import mock
import webapp2
import webtest
from ctc.helpers import csrf
from ctc.testing import testutil
MOCKED_TIME = 123
# Tests don't need docstrings, so pylint: disable=C0111
# Tests can test protected members, so pylint: disable=W0212
class CsrfTests(testutil.CtcTestCase):
# Helpers
class TestHandler(csrf.CsrfHandler):
"""A handler for testing whether or not requests are CSRF protected."""
def get(self):
self.response.write('CSRF Token:%s' % self.csrf_token)
def post(self):
pass
def put(self):
pass
def delete(self):
pass
def setUp(self):
super(CsrfTests, self).setUp()
# The CSRF library uses the time, so we mock it out.
self.time_mock = mock.Mock()
csrf.time = self.time_mock
self.time_mock.time = mock.Mock(return_value=MOCKED_TIME)
# The handler tests need a WSGIApplication.
app = webapp2.WSGIApplication([('/', self.TestHandler)])
self.testapp = webtest.TestApp(app)
def test_get_secret_key(self):
<|fim_middle|>
def test_tokens_are_equal(self):
# It should fail if the tokens aren't equal length.
self.assertFalse(csrf._tokens_are_equal('a', 'ab'))
# It should fail if the tokens are different.
self.assertFalse(csrf._tokens_are_equal('abcde', 'abcdf'))
# It should succeed if the tokens are the same.
self.assertTrue(csrf._tokens_are_equal('abcde', 'abcde'))
# Make Token
def test_make_token_includes_time(self):
self.login()
# It should get the current time.
token1 = csrf.make_token()
self.assertEqual(token1.split()[-1], str(MOCKED_TIME))
# It should use the provided time.
token2 = csrf.make_token(token_time='456')
self.assertEqual(token2.split()[-1], '456')
# Different time should cause the digest to be different.
self.assertNotEqual(token1.split()[0], token2.split()[0])
token3 = csrf.make_token(token_time='456')
self.assertEqual(token2, token3)
def test_make_token_requires_login(self):
token1 = csrf.make_token()
self.assertIsNone(token1)
self.login()
token2 = csrf.make_token()
self.assertIsNotNone(token2)
def test_make_token_includes_path(self):
self.login()
# It should get the current path.
self.testbed.setup_env(PATH_INFO='/action/1', overwrite=True)
token1 = csrf.make_token(token_time='123')
self.testbed.setup_env(PATH_INFO='/action/23', overwrite=True)
token2 = csrf.make_token(token_time='123')
token3 = csrf.make_token(token_time='123')
self.assertNotEqual(token1, token2)
self.assertEqual(token2, token3)
# It should let the client pass in a path.
token4 = csrf.make_token(path='/action/4', token_time='123')
token5 = csrf.make_token(path='/action/56', token_time='123')
token6 = csrf.make_token(path='/action/56', token_time='123')
self.assertNotEqual(token4, token5)
self.assertEqual(token5, token6)
# Token Is Valid
def test_token_is_valid(self):
self.login()
# Token is required.
self.assertFalse(csrf.token_is_valid(None))
# Token needs to have a timestamp on it.
self.assertFalse(csrf.token_is_valid('hello'))
# The timestamp needs to be within the current date range.
self.time_mock.time = mock.Mock(return_value=9999999999999)
self.assertFalse(csrf.token_is_valid('hello 123'))
# The user needs to be logged in.
token = csrf.make_token()
self.logout()
self.assertFalse(csrf.token_is_valid(token))
self.login()
# Modifying the token should break everything.
modified_token = '0' + token[1:]
if token == modified_token:
modified_token = '1' + token[1:]
self.assertFalse(csrf.token_is_valid(modified_token))
# The original token that we got should work.
self.assertTrue(csrf.token_is_valid(token))
def test_get_has_csrf_token(self):
self.login()
response = self.testapp.get('/', status=200).body
self.assertIn('CSRF Token:', response)
self.assertEqual(response.split(':')[-1], csrf.make_token())
def test_mutators_require_csrf_token(self):
self.login()
self.testapp.put('/', status=403)
self.testapp.post('/', status=403)
self.testapp.delete('/', status=403)
csrf_param = 'csrf_token=' + csrf.make_token(path='/')
self.testapp.put('/', params=csrf_param, status=200)
self.testapp.post('/', params=csrf_param, status=200)
# Though the spec allows DELETE to have a body, it tends to be ignored
# by servers (http://stackoverflow.com/questions/299628), and webapp2
# ignores it as well, so we have to put the params in the URL.
self.testapp.delete('/?' + csrf_param, status=200)
if __name__ == '__main__':
unittest.main()
<|fim▁end|> | first_key = csrf._get_secret_key()
self.assertEqual(len(first_key), 32)
second_key = csrf._get_secret_key()
self.assertEqual(first_key, second_key) |
<|file_name|>csrf_test.py<|end_file_name|><|fim▁begin|>"""Tests for the CSRF helper."""
import unittest
import mock
import webapp2
import webtest
from ctc.helpers import csrf
from ctc.testing import testutil
MOCKED_TIME = 123
# Tests don't need docstrings, so pylint: disable=C0111
# Tests can test protected members, so pylint: disable=W0212
class CsrfTests(testutil.CtcTestCase):
# Helpers
class TestHandler(csrf.CsrfHandler):
"""A handler for testing whether or not requests are CSRF protected."""
def get(self):
self.response.write('CSRF Token:%s' % self.csrf_token)
def post(self):
pass
def put(self):
pass
def delete(self):
pass
def setUp(self):
super(CsrfTests, self).setUp()
# The CSRF library uses the time, so we mock it out.
self.time_mock = mock.Mock()
csrf.time = self.time_mock
self.time_mock.time = mock.Mock(return_value=MOCKED_TIME)
# The handler tests need a WSGIApplication.
app = webapp2.WSGIApplication([('/', self.TestHandler)])
self.testapp = webtest.TestApp(app)
def test_get_secret_key(self):
first_key = csrf._get_secret_key()
self.assertEqual(len(first_key), 32)
second_key = csrf._get_secret_key()
self.assertEqual(first_key, second_key)
def test_tokens_are_equal(self):
# It should fail if the tokens aren't equal length.
<|fim_middle|>
# Make Token
def test_make_token_includes_time(self):
self.login()
# It should get the current time.
token1 = csrf.make_token()
self.assertEqual(token1.split()[-1], str(MOCKED_TIME))
# It should use the provided time.
token2 = csrf.make_token(token_time='456')
self.assertEqual(token2.split()[-1], '456')
# Different time should cause the digest to be different.
self.assertNotEqual(token1.split()[0], token2.split()[0])
token3 = csrf.make_token(token_time='456')
self.assertEqual(token2, token3)
def test_make_token_requires_login(self):
token1 = csrf.make_token()
self.assertIsNone(token1)
self.login()
token2 = csrf.make_token()
self.assertIsNotNone(token2)
def test_make_token_includes_path(self):
self.login()
# It should get the current path.
self.testbed.setup_env(PATH_INFO='/action/1', overwrite=True)
token1 = csrf.make_token(token_time='123')
self.testbed.setup_env(PATH_INFO='/action/23', overwrite=True)
token2 = csrf.make_token(token_time='123')
token3 = csrf.make_token(token_time='123')
self.assertNotEqual(token1, token2)
self.assertEqual(token2, token3)
# It should let the client pass in a path.
token4 = csrf.make_token(path='/action/4', token_time='123')
token5 = csrf.make_token(path='/action/56', token_time='123')
token6 = csrf.make_token(path='/action/56', token_time='123')
self.assertNotEqual(token4, token5)
self.assertEqual(token5, token6)
# Token Is Valid
def test_token_is_valid(self):
self.login()
# Token is required.
self.assertFalse(csrf.token_is_valid(None))
# Token needs to have a timestamp on it.
self.assertFalse(csrf.token_is_valid('hello'))
# The timestamp needs to be within the current date range.
self.time_mock.time = mock.Mock(return_value=9999999999999)
self.assertFalse(csrf.token_is_valid('hello 123'))
# The user needs to be logged in.
token = csrf.make_token()
self.logout()
self.assertFalse(csrf.token_is_valid(token))
self.login()
# Modifying the token should break everything.
modified_token = '0' + token[1:]
if token == modified_token:
modified_token = '1' + token[1:]
self.assertFalse(csrf.token_is_valid(modified_token))
# The original token that we got should work.
self.assertTrue(csrf.token_is_valid(token))
def test_get_has_csrf_token(self):
self.login()
response = self.testapp.get('/', status=200).body
self.assertIn('CSRF Token:', response)
self.assertEqual(response.split(':')[-1], csrf.make_token())
def test_mutators_require_csrf_token(self):
self.login()
self.testapp.put('/', status=403)
self.testapp.post('/', status=403)
self.testapp.delete('/', status=403)
csrf_param = 'csrf_token=' + csrf.make_token(path='/')
self.testapp.put('/', params=csrf_param, status=200)
self.testapp.post('/', params=csrf_param, status=200)
# Though the spec allows DELETE to have a body, it tends to be ignored
# by servers (http://stackoverflow.com/questions/299628), and webapp2
# ignores it as well, so we have to put the params in the URL.
self.testapp.delete('/?' + csrf_param, status=200)
if __name__ == '__main__':
unittest.main()
<|fim▁end|> | self.assertFalse(csrf._tokens_are_equal('a', 'ab'))
# It should fail if the tokens are different.
self.assertFalse(csrf._tokens_are_equal('abcde', 'abcdf'))
# It should succeed if the tokens are the same.
self.assertTrue(csrf._tokens_are_equal('abcde', 'abcde')) |
<|file_name|>csrf_test.py<|end_file_name|><|fim▁begin|>"""Tests for the CSRF helper."""
import unittest
import mock
import webapp2
import webtest
from ctc.helpers import csrf
from ctc.testing import testutil
MOCKED_TIME = 123
# Tests don't need docstrings, so pylint: disable=C0111
# Tests can test protected members, so pylint: disable=W0212
class CsrfTests(testutil.CtcTestCase):
# Helpers
class TestHandler(csrf.CsrfHandler):
"""A handler for testing whether or not requests are CSRF protected."""
def get(self):
self.response.write('CSRF Token:%s' % self.csrf_token)
def post(self):
pass
def put(self):
pass
def delete(self):
pass
def setUp(self):
super(CsrfTests, self).setUp()
# The CSRF library uses the time, so we mock it out.
self.time_mock = mock.Mock()
csrf.time = self.time_mock
self.time_mock.time = mock.Mock(return_value=MOCKED_TIME)
# The handler tests need a WSGIApplication.
app = webapp2.WSGIApplication([('/', self.TestHandler)])
self.testapp = webtest.TestApp(app)
def test_get_secret_key(self):
first_key = csrf._get_secret_key()
self.assertEqual(len(first_key), 32)
second_key = csrf._get_secret_key()
self.assertEqual(first_key, second_key)
def test_tokens_are_equal(self):
# It should fail if the tokens aren't equal length.
self.assertFalse(csrf._tokens_are_equal('a', 'ab'))
# It should fail if the tokens are different.
self.assertFalse(csrf._tokens_are_equal('abcde', 'abcdf'))
# It should succeed if the tokens are the same.
self.assertTrue(csrf._tokens_are_equal('abcde', 'abcde'))
# Make Token
def test_make_token_includes_time(self):
<|fim_middle|>
def test_make_token_requires_login(self):
token1 = csrf.make_token()
self.assertIsNone(token1)
self.login()
token2 = csrf.make_token()
self.assertIsNotNone(token2)
def test_make_token_includes_path(self):
self.login()
# It should get the current path.
self.testbed.setup_env(PATH_INFO='/action/1', overwrite=True)
token1 = csrf.make_token(token_time='123')
self.testbed.setup_env(PATH_INFO='/action/23', overwrite=True)
token2 = csrf.make_token(token_time='123')
token3 = csrf.make_token(token_time='123')
self.assertNotEqual(token1, token2)
self.assertEqual(token2, token3)
# It should let the client pass in a path.
token4 = csrf.make_token(path='/action/4', token_time='123')
token5 = csrf.make_token(path='/action/56', token_time='123')
token6 = csrf.make_token(path='/action/56', token_time='123')
self.assertNotEqual(token4, token5)
self.assertEqual(token5, token6)
# Token Is Valid
def test_token_is_valid(self):
self.login()
# Token is required.
self.assertFalse(csrf.token_is_valid(None))
# Token needs to have a timestamp on it.
self.assertFalse(csrf.token_is_valid('hello'))
# The timestamp needs to be within the current date range.
self.time_mock.time = mock.Mock(return_value=9999999999999)
self.assertFalse(csrf.token_is_valid('hello 123'))
# The user needs to be logged in.
token = csrf.make_token()
self.logout()
self.assertFalse(csrf.token_is_valid(token))
self.login()
# Modifying the token should break everything.
modified_token = '0' + token[1:]
if token == modified_token:
modified_token = '1' + token[1:]
self.assertFalse(csrf.token_is_valid(modified_token))
# The original token that we got should work.
self.assertTrue(csrf.token_is_valid(token))
def test_get_has_csrf_token(self):
self.login()
response = self.testapp.get('/', status=200).body
self.assertIn('CSRF Token:', response)
self.assertEqual(response.split(':')[-1], csrf.make_token())
def test_mutators_require_csrf_token(self):
self.login()
self.testapp.put('/', status=403)
self.testapp.post('/', status=403)
self.testapp.delete('/', status=403)
csrf_param = 'csrf_token=' + csrf.make_token(path='/')
self.testapp.put('/', params=csrf_param, status=200)
self.testapp.post('/', params=csrf_param, status=200)
# Though the spec allows DELETE to have a body, it tends to be ignored
# by servers (http://stackoverflow.com/questions/299628), and webapp2
# ignores it as well, so we have to put the params in the URL.
self.testapp.delete('/?' + csrf_param, status=200)
if __name__ == '__main__':
unittest.main()
<|fim▁end|> | self.login()
# It should get the current time.
token1 = csrf.make_token()
self.assertEqual(token1.split()[-1], str(MOCKED_TIME))
# It should use the provided time.
token2 = csrf.make_token(token_time='456')
self.assertEqual(token2.split()[-1], '456')
# Different time should cause the digest to be different.
self.assertNotEqual(token1.split()[0], token2.split()[0])
token3 = csrf.make_token(token_time='456')
self.assertEqual(token2, token3) |
<|file_name|>csrf_test.py<|end_file_name|><|fim▁begin|>"""Tests for the CSRF helper."""
import unittest
import mock
import webapp2
import webtest
from ctc.helpers import csrf
from ctc.testing import testutil
MOCKED_TIME = 123
# Tests don't need docstrings, so pylint: disable=C0111
# Tests can test protected members, so pylint: disable=W0212
class CsrfTests(testutil.CtcTestCase):
# Helpers
class TestHandler(csrf.CsrfHandler):
"""A handler for testing whether or not requests are CSRF protected."""
def get(self):
self.response.write('CSRF Token:%s' % self.csrf_token)
def post(self):
pass
def put(self):
pass
def delete(self):
pass
def setUp(self):
super(CsrfTests, self).setUp()
# The CSRF library uses the time, so we mock it out.
self.time_mock = mock.Mock()
csrf.time = self.time_mock
self.time_mock.time = mock.Mock(return_value=MOCKED_TIME)
# The handler tests need a WSGIApplication.
app = webapp2.WSGIApplication([('/', self.TestHandler)])
self.testapp = webtest.TestApp(app)
def test_get_secret_key(self):
first_key = csrf._get_secret_key()
self.assertEqual(len(first_key), 32)
second_key = csrf._get_secret_key()
self.assertEqual(first_key, second_key)
def test_tokens_are_equal(self):
# It should fail if the tokens aren't equal length.
self.assertFalse(csrf._tokens_are_equal('a', 'ab'))
# It should fail if the tokens are different.
self.assertFalse(csrf._tokens_are_equal('abcde', 'abcdf'))
# It should succeed if the tokens are the same.
self.assertTrue(csrf._tokens_are_equal('abcde', 'abcde'))
# Make Token
def test_make_token_includes_time(self):
self.login()
# It should get the current time.
token1 = csrf.make_token()
self.assertEqual(token1.split()[-1], str(MOCKED_TIME))
# It should use the provided time.
token2 = csrf.make_token(token_time='456')
self.assertEqual(token2.split()[-1], '456')
# Different time should cause the digest to be different.
self.assertNotEqual(token1.split()[0], token2.split()[0])
token3 = csrf.make_token(token_time='456')
self.assertEqual(token2, token3)
def test_make_token_requires_login(self):
<|fim_middle|>
def test_make_token_includes_path(self):
self.login()
# It should get the current path.
self.testbed.setup_env(PATH_INFO='/action/1', overwrite=True)
token1 = csrf.make_token(token_time='123')
self.testbed.setup_env(PATH_INFO='/action/23', overwrite=True)
token2 = csrf.make_token(token_time='123')
token3 = csrf.make_token(token_time='123')
self.assertNotEqual(token1, token2)
self.assertEqual(token2, token3)
# It should let the client pass in a path.
token4 = csrf.make_token(path='/action/4', token_time='123')
token5 = csrf.make_token(path='/action/56', token_time='123')
token6 = csrf.make_token(path='/action/56', token_time='123')
self.assertNotEqual(token4, token5)
self.assertEqual(token5, token6)
# Token Is Valid
def test_token_is_valid(self):
self.login()
# Token is required.
self.assertFalse(csrf.token_is_valid(None))
# Token needs to have a timestamp on it.
self.assertFalse(csrf.token_is_valid('hello'))
# The timestamp needs to be within the current date range.
self.time_mock.time = mock.Mock(return_value=9999999999999)
self.assertFalse(csrf.token_is_valid('hello 123'))
# The user needs to be logged in.
token = csrf.make_token()
self.logout()
self.assertFalse(csrf.token_is_valid(token))
self.login()
# Modifying the token should break everything.
modified_token = '0' + token[1:]
if token == modified_token:
modified_token = '1' + token[1:]
self.assertFalse(csrf.token_is_valid(modified_token))
# The original token that we got should work.
self.assertTrue(csrf.token_is_valid(token))
def test_get_has_csrf_token(self):
self.login()
response = self.testapp.get('/', status=200).body
self.assertIn('CSRF Token:', response)
self.assertEqual(response.split(':')[-1], csrf.make_token())
def test_mutators_require_csrf_token(self):
self.login()
self.testapp.put('/', status=403)
self.testapp.post('/', status=403)
self.testapp.delete('/', status=403)
csrf_param = 'csrf_token=' + csrf.make_token(path='/')
self.testapp.put('/', params=csrf_param, status=200)
self.testapp.post('/', params=csrf_param, status=200)
# Though the spec allows DELETE to have a body, it tends to be ignored
# by servers (http://stackoverflow.com/questions/299628), and webapp2
# ignores it as well, so we have to put the params in the URL.
self.testapp.delete('/?' + csrf_param, status=200)
if __name__ == '__main__':
unittest.main()
<|fim▁end|> | token1 = csrf.make_token()
self.assertIsNone(token1)
self.login()
token2 = csrf.make_token()
self.assertIsNotNone(token2) |
<|file_name|>csrf_test.py<|end_file_name|><|fim▁begin|>"""Tests for the CSRF helper."""
import unittest
import mock
import webapp2
import webtest
from ctc.helpers import csrf
from ctc.testing import testutil
MOCKED_TIME = 123
# Tests don't need docstrings, so pylint: disable=C0111
# Tests can test protected members, so pylint: disable=W0212
class CsrfTests(testutil.CtcTestCase):
# Helpers
class TestHandler(csrf.CsrfHandler):
"""A handler for testing whether or not requests are CSRF protected."""
def get(self):
self.response.write('CSRF Token:%s' % self.csrf_token)
def post(self):
pass
def put(self):
pass
def delete(self):
pass
def setUp(self):
super(CsrfTests, self).setUp()
# The CSRF library uses the time, so we mock it out.
self.time_mock = mock.Mock()
csrf.time = self.time_mock
self.time_mock.time = mock.Mock(return_value=MOCKED_TIME)
# The handler tests need a WSGIApplication.
app = webapp2.WSGIApplication([('/', self.TestHandler)])
self.testapp = webtest.TestApp(app)
def test_get_secret_key(self):
first_key = csrf._get_secret_key()
self.assertEqual(len(first_key), 32)
second_key = csrf._get_secret_key()
self.assertEqual(first_key, second_key)
def test_tokens_are_equal(self):
# It should fail if the tokens aren't equal length.
self.assertFalse(csrf._tokens_are_equal('a', 'ab'))
# It should fail if the tokens are different.
self.assertFalse(csrf._tokens_are_equal('abcde', 'abcdf'))
# It should succeed if the tokens are the same.
self.assertTrue(csrf._tokens_are_equal('abcde', 'abcde'))
# Make Token
def test_make_token_includes_time(self):
self.login()
# It should get the current time.
token1 = csrf.make_token()
self.assertEqual(token1.split()[-1], str(MOCKED_TIME))
# It should use the provided time.
token2 = csrf.make_token(token_time='456')
self.assertEqual(token2.split()[-1], '456')
# Different time should cause the digest to be different.
self.assertNotEqual(token1.split()[0], token2.split()[0])
token3 = csrf.make_token(token_time='456')
self.assertEqual(token2, token3)
def test_make_token_requires_login(self):
token1 = csrf.make_token()
self.assertIsNone(token1)
self.login()
token2 = csrf.make_token()
self.assertIsNotNone(token2)
def test_make_token_includes_path(self):
<|fim_middle|>
# Token Is Valid
def test_token_is_valid(self):
self.login()
# Token is required.
self.assertFalse(csrf.token_is_valid(None))
# Token needs to have a timestamp on it.
self.assertFalse(csrf.token_is_valid('hello'))
# The timestamp needs to be within the current date range.
self.time_mock.time = mock.Mock(return_value=9999999999999)
self.assertFalse(csrf.token_is_valid('hello 123'))
# The user needs to be logged in.
token = csrf.make_token()
self.logout()
self.assertFalse(csrf.token_is_valid(token))
self.login()
# Modifying the token should break everything.
modified_token = '0' + token[1:]
if token == modified_token:
modified_token = '1' + token[1:]
self.assertFalse(csrf.token_is_valid(modified_token))
# The original token that we got should work.
self.assertTrue(csrf.token_is_valid(token))
def test_get_has_csrf_token(self):
self.login()
response = self.testapp.get('/', status=200).body
self.assertIn('CSRF Token:', response)
self.assertEqual(response.split(':')[-1], csrf.make_token())
def test_mutators_require_csrf_token(self):
self.login()
self.testapp.put('/', status=403)
self.testapp.post('/', status=403)
self.testapp.delete('/', status=403)
csrf_param = 'csrf_token=' + csrf.make_token(path='/')
self.testapp.put('/', params=csrf_param, status=200)
self.testapp.post('/', params=csrf_param, status=200)
# Though the spec allows DELETE to have a body, it tends to be ignored
# by servers (http://stackoverflow.com/questions/299628), and webapp2
# ignores it as well, so we have to put the params in the URL.
self.testapp.delete('/?' + csrf_param, status=200)
if __name__ == '__main__':
unittest.main()
<|fim▁end|> | self.login()
# It should get the current path.
self.testbed.setup_env(PATH_INFO='/action/1', overwrite=True)
token1 = csrf.make_token(token_time='123')
self.testbed.setup_env(PATH_INFO='/action/23', overwrite=True)
token2 = csrf.make_token(token_time='123')
token3 = csrf.make_token(token_time='123')
self.assertNotEqual(token1, token2)
self.assertEqual(token2, token3)
# It should let the client pass in a path.
token4 = csrf.make_token(path='/action/4', token_time='123')
token5 = csrf.make_token(path='/action/56', token_time='123')
token6 = csrf.make_token(path='/action/56', token_time='123')
self.assertNotEqual(token4, token5)
self.assertEqual(token5, token6) |
<|file_name|>csrf_test.py<|end_file_name|><|fim▁begin|>"""Tests for the CSRF helper."""
import unittest
import mock
import webapp2
import webtest
from ctc.helpers import csrf
from ctc.testing import testutil
MOCKED_TIME = 123
# Tests don't need docstrings, so pylint: disable=C0111
# Tests can test protected members, so pylint: disable=W0212
class CsrfTests(testutil.CtcTestCase):
# Helpers
class TestHandler(csrf.CsrfHandler):
"""A handler for testing whether or not requests are CSRF protected."""
def get(self):
self.response.write('CSRF Token:%s' % self.csrf_token)
def post(self):
pass
def put(self):
pass
def delete(self):
pass
def setUp(self):
super(CsrfTests, self).setUp()
# The CSRF library uses the time, so we mock it out.
self.time_mock = mock.Mock()
csrf.time = self.time_mock
self.time_mock.time = mock.Mock(return_value=MOCKED_TIME)
# The handler tests need a WSGIApplication.
app = webapp2.WSGIApplication([('/', self.TestHandler)])
self.testapp = webtest.TestApp(app)
def test_get_secret_key(self):
first_key = csrf._get_secret_key()
self.assertEqual(len(first_key), 32)
second_key = csrf._get_secret_key()
self.assertEqual(first_key, second_key)
def test_tokens_are_equal(self):
# It should fail if the tokens aren't equal length.
self.assertFalse(csrf._tokens_are_equal('a', 'ab'))
# It should fail if the tokens are different.
self.assertFalse(csrf._tokens_are_equal('abcde', 'abcdf'))
# It should succeed if the tokens are the same.
self.assertTrue(csrf._tokens_are_equal('abcde', 'abcde'))
# Make Token
def test_make_token_includes_time(self):
self.login()
# It should get the current time.
token1 = csrf.make_token()
self.assertEqual(token1.split()[-1], str(MOCKED_TIME))
# It should use the provided time.
token2 = csrf.make_token(token_time='456')
self.assertEqual(token2.split()[-1], '456')
# Different time should cause the digest to be different.
self.assertNotEqual(token1.split()[0], token2.split()[0])
token3 = csrf.make_token(token_time='456')
self.assertEqual(token2, token3)
def test_make_token_requires_login(self):
token1 = csrf.make_token()
self.assertIsNone(token1)
self.login()
token2 = csrf.make_token()
self.assertIsNotNone(token2)
def test_make_token_includes_path(self):
self.login()
# It should get the current path.
self.testbed.setup_env(PATH_INFO='/action/1', overwrite=True)
token1 = csrf.make_token(token_time='123')
self.testbed.setup_env(PATH_INFO='/action/23', overwrite=True)
token2 = csrf.make_token(token_time='123')
token3 = csrf.make_token(token_time='123')
self.assertNotEqual(token1, token2)
self.assertEqual(token2, token3)
# It should let the client pass in a path.
token4 = csrf.make_token(path='/action/4', token_time='123')
token5 = csrf.make_token(path='/action/56', token_time='123')
token6 = csrf.make_token(path='/action/56', token_time='123')
self.assertNotEqual(token4, token5)
self.assertEqual(token5, token6)
# Token Is Valid
def test_token_is_valid(self):
<|fim_middle|>
def test_get_has_csrf_token(self):
self.login()
response = self.testapp.get('/', status=200).body
self.assertIn('CSRF Token:', response)
self.assertEqual(response.split(':')[-1], csrf.make_token())
def test_mutators_require_csrf_token(self):
self.login()
self.testapp.put('/', status=403)
self.testapp.post('/', status=403)
self.testapp.delete('/', status=403)
csrf_param = 'csrf_token=' + csrf.make_token(path='/')
self.testapp.put('/', params=csrf_param, status=200)
self.testapp.post('/', params=csrf_param, status=200)
# Though the spec allows DELETE to have a body, it tends to be ignored
# by servers (http://stackoverflow.com/questions/299628), and webapp2
# ignores it as well, so we have to put the params in the URL.
self.testapp.delete('/?' + csrf_param, status=200)
if __name__ == '__main__':
unittest.main()
<|fim▁end|> | self.login()
# Token is required.
self.assertFalse(csrf.token_is_valid(None))
# Token needs to have a timestamp on it.
self.assertFalse(csrf.token_is_valid('hello'))
# The timestamp needs to be within the current date range.
self.time_mock.time = mock.Mock(return_value=9999999999999)
self.assertFalse(csrf.token_is_valid('hello 123'))
# The user needs to be logged in.
token = csrf.make_token()
self.logout()
self.assertFalse(csrf.token_is_valid(token))
self.login()
# Modifying the token should break everything.
modified_token = '0' + token[1:]
if token == modified_token:
modified_token = '1' + token[1:]
self.assertFalse(csrf.token_is_valid(modified_token))
# The original token that we got should work.
self.assertTrue(csrf.token_is_valid(token)) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.