prompt
large_stringlengths
72
9.34k
completion
large_stringlengths
0
7.61k
<|file_name|>main.py<|end_file_name|><|fim▁begin|>from kivy.lib import osc from time import sleep import pocketclient from kivy.utils import platform as kivy_platform SERVICE_PORT = 4000 def <|fim_middle|>(): p = kivy_platform() if p.lower() in ('linux', 'waindows', 'osx'): return 'desktop' else: return p class Service(object): def __init__(self): osc.init() self.last_update = 0 self.oscid = osc.listen(ipAddr='localhost', port=SERVICE_PORT) osc.bind(self.oscid, self.pocket_connect, '/pocket/connect') osc.bind(self.oscid, self.pocket_list, '/pocket/list') osc.bind(self.oscid, self.pocket_mark_read, '/pocket/mark_read') def send(self, **kwargs): osc.sendMsg() def run(self): while self._run: osc.readQueue(self.oscid) sleep(.1) def pocket_connect(self, **kwargs): if 'token' in kwargs: self.token = kwargs['token'] else: pocketclient.authorize(platform(), self.save_pocket_token) def save_pocket_token(self, api_key, token, username): self.token = { 'key': api_key, 'token': token, 'username': username } def pocket_list(self, *args): if not self.token: if self.pocket_last_update: pocketclient.get_items(self. else: pass pass def pocket_mark_read(self, *args): pass if __name__ == '__main__': Service().run() <|fim▁end|>
platform
<|file_name|>main.py<|end_file_name|><|fim▁begin|>from kivy.lib import osc from time import sleep import pocketclient from kivy.utils import platform as kivy_platform SERVICE_PORT = 4000 def platform(): p = kivy_platform() if p.lower() in ('linux', 'waindows', 'osx'): return 'desktop' else: return p class Service(object): def <|fim_middle|>(self): osc.init() self.last_update = 0 self.oscid = osc.listen(ipAddr='localhost', port=SERVICE_PORT) osc.bind(self.oscid, self.pocket_connect, '/pocket/connect') osc.bind(self.oscid, self.pocket_list, '/pocket/list') osc.bind(self.oscid, self.pocket_mark_read, '/pocket/mark_read') def send(self, **kwargs): osc.sendMsg() def run(self): while self._run: osc.readQueue(self.oscid) sleep(.1) def pocket_connect(self, **kwargs): if 'token' in kwargs: self.token = kwargs['token'] else: pocketclient.authorize(platform(), self.save_pocket_token) def save_pocket_token(self, api_key, token, username): self.token = { 'key': api_key, 'token': token, 'username': username } def pocket_list(self, *args): if not self.token: if self.pocket_last_update: pocketclient.get_items(self. else: pass pass def pocket_mark_read(self, *args): pass if __name__ == '__main__': Service().run() <|fim▁end|>
__init__
<|file_name|>main.py<|end_file_name|><|fim▁begin|>from kivy.lib import osc from time import sleep import pocketclient from kivy.utils import platform as kivy_platform SERVICE_PORT = 4000 def platform(): p = kivy_platform() if p.lower() in ('linux', 'waindows', 'osx'): return 'desktop' else: return p class Service(object): def __init__(self): osc.init() self.last_update = 0 self.oscid = osc.listen(ipAddr='localhost', port=SERVICE_PORT) osc.bind(self.oscid, self.pocket_connect, '/pocket/connect') osc.bind(self.oscid, self.pocket_list, '/pocket/list') osc.bind(self.oscid, self.pocket_mark_read, '/pocket/mark_read') def <|fim_middle|>(self, **kwargs): osc.sendMsg() def run(self): while self._run: osc.readQueue(self.oscid) sleep(.1) def pocket_connect(self, **kwargs): if 'token' in kwargs: self.token = kwargs['token'] else: pocketclient.authorize(platform(), self.save_pocket_token) def save_pocket_token(self, api_key, token, username): self.token = { 'key': api_key, 'token': token, 'username': username } def pocket_list(self, *args): if not self.token: if self.pocket_last_update: pocketclient.get_items(self. else: pass pass def pocket_mark_read(self, *args): pass if __name__ == '__main__': Service().run() <|fim▁end|>
send
<|file_name|>main.py<|end_file_name|><|fim▁begin|>from kivy.lib import osc from time import sleep import pocketclient from kivy.utils import platform as kivy_platform SERVICE_PORT = 4000 def platform(): p = kivy_platform() if p.lower() in ('linux', 'waindows', 'osx'): return 'desktop' else: return p class Service(object): def __init__(self): osc.init() self.last_update = 0 self.oscid = osc.listen(ipAddr='localhost', port=SERVICE_PORT) osc.bind(self.oscid, self.pocket_connect, '/pocket/connect') osc.bind(self.oscid, self.pocket_list, '/pocket/list') osc.bind(self.oscid, self.pocket_mark_read, '/pocket/mark_read') def send(self, **kwargs): osc.sendMsg() def <|fim_middle|>(self): while self._run: osc.readQueue(self.oscid) sleep(.1) def pocket_connect(self, **kwargs): if 'token' in kwargs: self.token = kwargs['token'] else: pocketclient.authorize(platform(), self.save_pocket_token) def save_pocket_token(self, api_key, token, username): self.token = { 'key': api_key, 'token': token, 'username': username } def pocket_list(self, *args): if not self.token: if self.pocket_last_update: pocketclient.get_items(self. else: pass pass def pocket_mark_read(self, *args): pass if __name__ == '__main__': Service().run() <|fim▁end|>
run
<|file_name|>main.py<|end_file_name|><|fim▁begin|>from kivy.lib import osc from time import sleep import pocketclient from kivy.utils import platform as kivy_platform SERVICE_PORT = 4000 def platform(): p = kivy_platform() if p.lower() in ('linux', 'waindows', 'osx'): return 'desktop' else: return p class Service(object): def __init__(self): osc.init() self.last_update = 0 self.oscid = osc.listen(ipAddr='localhost', port=SERVICE_PORT) osc.bind(self.oscid, self.pocket_connect, '/pocket/connect') osc.bind(self.oscid, self.pocket_list, '/pocket/list') osc.bind(self.oscid, self.pocket_mark_read, '/pocket/mark_read') def send(self, **kwargs): osc.sendMsg() def run(self): while self._run: osc.readQueue(self.oscid) sleep(.1) def <|fim_middle|>(self, **kwargs): if 'token' in kwargs: self.token = kwargs['token'] else: pocketclient.authorize(platform(), self.save_pocket_token) def save_pocket_token(self, api_key, token, username): self.token = { 'key': api_key, 'token': token, 'username': username } def pocket_list(self, *args): if not self.token: if self.pocket_last_update: pocketclient.get_items(self. else: pass pass def pocket_mark_read(self, *args): pass if __name__ == '__main__': Service().run() <|fim▁end|>
pocket_connect
<|file_name|>main.py<|end_file_name|><|fim▁begin|>from kivy.lib import osc from time import sleep import pocketclient from kivy.utils import platform as kivy_platform SERVICE_PORT = 4000 def platform(): p = kivy_platform() if p.lower() in ('linux', 'waindows', 'osx'): return 'desktop' else: return p class Service(object): def __init__(self): osc.init() self.last_update = 0 self.oscid = osc.listen(ipAddr='localhost', port=SERVICE_PORT) osc.bind(self.oscid, self.pocket_connect, '/pocket/connect') osc.bind(self.oscid, self.pocket_list, '/pocket/list') osc.bind(self.oscid, self.pocket_mark_read, '/pocket/mark_read') def send(self, **kwargs): osc.sendMsg() def run(self): while self._run: osc.readQueue(self.oscid) sleep(.1) def pocket_connect(self, **kwargs): if 'token' in kwargs: self.token = kwargs['token'] else: pocketclient.authorize(platform(), self.save_pocket_token) def <|fim_middle|>(self, api_key, token, username): self.token = { 'key': api_key, 'token': token, 'username': username } def pocket_list(self, *args): if not self.token: if self.pocket_last_update: pocketclient.get_items(self. else: pass pass def pocket_mark_read(self, *args): pass if __name__ == '__main__': Service().run() <|fim▁end|>
save_pocket_token
<|file_name|>main.py<|end_file_name|><|fim▁begin|>from kivy.lib import osc from time import sleep import pocketclient from kivy.utils import platform as kivy_platform SERVICE_PORT = 4000 def platform(): p = kivy_platform() if p.lower() in ('linux', 'waindows', 'osx'): return 'desktop' else: return p class Service(object): def __init__(self): osc.init() self.last_update = 0 self.oscid = osc.listen(ipAddr='localhost', port=SERVICE_PORT) osc.bind(self.oscid, self.pocket_connect, '/pocket/connect') osc.bind(self.oscid, self.pocket_list, '/pocket/list') osc.bind(self.oscid, self.pocket_mark_read, '/pocket/mark_read') def send(self, **kwargs): osc.sendMsg() def run(self): while self._run: osc.readQueue(self.oscid) sleep(.1) def pocket_connect(self, **kwargs): if 'token' in kwargs: self.token = kwargs['token'] else: pocketclient.authorize(platform(), self.save_pocket_token) def save_pocket_token(self, api_key, token, username): self.token = { 'key': api_key, 'token': token, 'username': username } def <|fim_middle|>(self, *args): if not self.token: if self.pocket_last_update: pocketclient.get_items(self. else: pass pass def pocket_mark_read(self, *args): pass if __name__ == '__main__': Service().run() <|fim▁end|>
pocket_list
<|file_name|>main.py<|end_file_name|><|fim▁begin|>from kivy.lib import osc from time import sleep import pocketclient from kivy.utils import platform as kivy_platform SERVICE_PORT = 4000 def platform(): p = kivy_platform() if p.lower() in ('linux', 'waindows', 'osx'): return 'desktop' else: return p class Service(object): def __init__(self): osc.init() self.last_update = 0 self.oscid = osc.listen(ipAddr='localhost', port=SERVICE_PORT) osc.bind(self.oscid, self.pocket_connect, '/pocket/connect') osc.bind(self.oscid, self.pocket_list, '/pocket/list') osc.bind(self.oscid, self.pocket_mark_read, '/pocket/mark_read') def send(self, **kwargs): osc.sendMsg() def run(self): while self._run: osc.readQueue(self.oscid) sleep(.1) def pocket_connect(self, **kwargs): if 'token' in kwargs: self.token = kwargs['token'] else: pocketclient.authorize(platform(), self.save_pocket_token) def save_pocket_token(self, api_key, token, username): self.token = { 'key': api_key, 'token': token, 'username': username } def pocket_list(self, *args): if not self.token: if self.pocket_last_update: pocketclient.get_items(self. else: pass pass def <|fim_middle|>(self, *args): pass if __name__ == '__main__': Service().run() <|fim▁end|>
pocket_mark_read
<|file_name|>WpApiParser.py<|end_file_name|><|fim▁begin|>from cse.util import Util from collections import OrderedDict from cse.pipeline import Handler class WpApiParser(Handler): def __init__(self): super() def parse(self, comments, url, assetId, parentId): data = self.__buildDataSkeleton(url, assetId) data["comments"] = self.__iterateComments(comments, parentId) return data def __buildDataSkeleton(self, url, assetId): return { "article_url" : url, "article_id" : assetId, "comments" : None } def __iterateComments(self, comments, parentId=None): commentList = OrderedDict() for comment in comments: votes = 0 for action_summary in comment["action_summaries"]: if action_summary["__typename"] == "LikeActionSummary": <|fim_middle|> commentObject = { "comment_author": comment["user"]["username"], "comment_text" : comment["body"], "timestamp" : comment["created_at"], "parent_comment_id" : parentId, "upvotes" : votes, "downvotes": 0 } commentList[comment["id"]] = commentObject try: commentReplies = self.__iterateComments(comment["replies"]["nodes"], comment["id"]) except KeyError: # There may be a limit of the nesting level of comments on wp commentReplies = {} commentList.update(commentReplies) return commentList # inherited from cse.pipeline.Handler def registeredAt(self, ctx): pass def process(self, ctx, data): result = self.parse( comments=data["comments"], url=data["url"], assetId=data["assetId"], parentId=data["parentId"] ) ctx.write(result) <|fim▁end|>
votes = action_summary["count"]
<|file_name|>WpApiParser.py<|end_file_name|><|fim▁begin|>from cse.util import Util from collections import OrderedDict from cse.pipeline import Handler class WpApiParser(Handler): def __init__(self): super() def parse(self, comments, url, assetId, parentId): data = self.__buildDataSkeleton(url, assetId) data["comments"] = self.__iterateComments(comments, parentId) return data def __buildDataSkeleton(self, url, assetId): return { "article_url" : url, "article_id" : assetId, "comments" : None } def __iterateComments(self, comments, parentId=None): commentList = OrderedDict() for comment in comments: votes = 0 for action_summary in comment["action_summaries"]: if action_summary["__typename"] == "LikeActionSummary": votes = action_summary["count"] commentObject = { "comment_author": comment["user"]["username"], "comment_text" : comment["body"],<|fim▁hole|> "timestamp" : comment["created_at"], "parent_comment_id" : parentId, "upvotes" : votes, "downvotes": 0 } commentList[comment["id"]] = commentObject try: commentReplies = self.__iterateComments(comment["replies"]["nodes"], comment["id"]) except KeyError: # There may be a limit of the nesting level of comments on wp commentReplies = {} commentList.update(commentReplies) return commentList # inherited from cse.pipeline.Handler def registeredAt(self, ctx): pass def process(self, ctx, data): result = self.parse( comments=data["comments"], url=data["url"], assetId=data["assetId"], parentId=data["parentId"] ) ctx.write(result)<|fim▁end|>
<|file_name|>WpApiParser.py<|end_file_name|><|fim▁begin|>from cse.util import Util from collections import OrderedDict from cse.pipeline import Handler class WpApiParser(Handler): <|fim_middle|> <|fim▁end|>
def __init__(self): super() def parse(self, comments, url, assetId, parentId): data = self.__buildDataSkeleton(url, assetId) data["comments"] = self.__iterateComments(comments, parentId) return data def __buildDataSkeleton(self, url, assetId): return { "article_url" : url, "article_id" : assetId, "comments" : None } def __iterateComments(self, comments, parentId=None): commentList = OrderedDict() for comment in comments: votes = 0 for action_summary in comment["action_summaries"]: if action_summary["__typename"] == "LikeActionSummary": votes = action_summary["count"] commentObject = { "comment_author": comment["user"]["username"], "comment_text" : comment["body"], "timestamp" : comment["created_at"], "parent_comment_id" : parentId, "upvotes" : votes, "downvotes": 0 } commentList[comment["id"]] = commentObject try: commentReplies = self.__iterateComments(comment["replies"]["nodes"], comment["id"]) except KeyError: # There may be a limit of the nesting level of comments on wp commentReplies = {} commentList.update(commentReplies) return commentList # inherited from cse.pipeline.Handler def registeredAt(self, ctx): pass def process(self, ctx, data): result = self.parse( comments=data["comments"], url=data["url"], assetId=data["assetId"], parentId=data["parentId"] ) ctx.write(result)
<|file_name|>WpApiParser.py<|end_file_name|><|fim▁begin|>from cse.util import Util from collections import OrderedDict from cse.pipeline import Handler class WpApiParser(Handler): def __init__(self): <|fim_middle|> def parse(self, comments, url, assetId, parentId): data = self.__buildDataSkeleton(url, assetId) data["comments"] = self.__iterateComments(comments, parentId) return data def __buildDataSkeleton(self, url, assetId): return { "article_url" : url, "article_id" : assetId, "comments" : None } def __iterateComments(self, comments, parentId=None): commentList = OrderedDict() for comment in comments: votes = 0 for action_summary in comment["action_summaries"]: if action_summary["__typename"] == "LikeActionSummary": votes = action_summary["count"] commentObject = { "comment_author": comment["user"]["username"], "comment_text" : comment["body"], "timestamp" : comment["created_at"], "parent_comment_id" : parentId, "upvotes" : votes, "downvotes": 0 } commentList[comment["id"]] = commentObject try: commentReplies = self.__iterateComments(comment["replies"]["nodes"], comment["id"]) except KeyError: # There may be a limit of the nesting level of comments on wp commentReplies = {} commentList.update(commentReplies) return commentList # inherited from cse.pipeline.Handler def registeredAt(self, ctx): pass def process(self, ctx, data): result = self.parse( comments=data["comments"], url=data["url"], assetId=data["assetId"], parentId=data["parentId"] ) ctx.write(result) <|fim▁end|>
super()
<|file_name|>WpApiParser.py<|end_file_name|><|fim▁begin|>from cse.util import Util from collections import OrderedDict from cse.pipeline import Handler class WpApiParser(Handler): def __init__(self): super() def parse(self, comments, url, assetId, parentId): <|fim_middle|> def __buildDataSkeleton(self, url, assetId): return { "article_url" : url, "article_id" : assetId, "comments" : None } def __iterateComments(self, comments, parentId=None): commentList = OrderedDict() for comment in comments: votes = 0 for action_summary in comment["action_summaries"]: if action_summary["__typename"] == "LikeActionSummary": votes = action_summary["count"] commentObject = { "comment_author": comment["user"]["username"], "comment_text" : comment["body"], "timestamp" : comment["created_at"], "parent_comment_id" : parentId, "upvotes" : votes, "downvotes": 0 } commentList[comment["id"]] = commentObject try: commentReplies = self.__iterateComments(comment["replies"]["nodes"], comment["id"]) except KeyError: # There may be a limit of the nesting level of comments on wp commentReplies = {} commentList.update(commentReplies) return commentList # inherited from cse.pipeline.Handler def registeredAt(self, ctx): pass def process(self, ctx, data): result = self.parse( comments=data["comments"], url=data["url"], assetId=data["assetId"], parentId=data["parentId"] ) ctx.write(result) <|fim▁end|>
data = self.__buildDataSkeleton(url, assetId) data["comments"] = self.__iterateComments(comments, parentId) return data
<|file_name|>WpApiParser.py<|end_file_name|><|fim▁begin|>from cse.util import Util from collections import OrderedDict from cse.pipeline import Handler class WpApiParser(Handler): def __init__(self): super() def parse(self, comments, url, assetId, parentId): data = self.__buildDataSkeleton(url, assetId) data["comments"] = self.__iterateComments(comments, parentId) return data def __buildDataSkeleton(self, url, assetId): <|fim_middle|> def __iterateComments(self, comments, parentId=None): commentList = OrderedDict() for comment in comments: votes = 0 for action_summary in comment["action_summaries"]: if action_summary["__typename"] == "LikeActionSummary": votes = action_summary["count"] commentObject = { "comment_author": comment["user"]["username"], "comment_text" : comment["body"], "timestamp" : comment["created_at"], "parent_comment_id" : parentId, "upvotes" : votes, "downvotes": 0 } commentList[comment["id"]] = commentObject try: commentReplies = self.__iterateComments(comment["replies"]["nodes"], comment["id"]) except KeyError: # There may be a limit of the nesting level of comments on wp commentReplies = {} commentList.update(commentReplies) return commentList # inherited from cse.pipeline.Handler def registeredAt(self, ctx): pass def process(self, ctx, data): result = self.parse( comments=data["comments"], url=data["url"], assetId=data["assetId"], parentId=data["parentId"] ) ctx.write(result) <|fim▁end|>
return { "article_url" : url, "article_id" : assetId, "comments" : None }
<|file_name|>WpApiParser.py<|end_file_name|><|fim▁begin|>from cse.util import Util from collections import OrderedDict from cse.pipeline import Handler class WpApiParser(Handler): def __init__(self): super() def parse(self, comments, url, assetId, parentId): data = self.__buildDataSkeleton(url, assetId) data["comments"] = self.__iterateComments(comments, parentId) return data def __buildDataSkeleton(self, url, assetId): return { "article_url" : url, "article_id" : assetId, "comments" : None } def __iterateComments(self, comments, parentId=None): <|fim_middle|> # inherited from cse.pipeline.Handler def registeredAt(self, ctx): pass def process(self, ctx, data): result = self.parse( comments=data["comments"], url=data["url"], assetId=data["assetId"], parentId=data["parentId"] ) ctx.write(result) <|fim▁end|>
commentList = OrderedDict() for comment in comments: votes = 0 for action_summary in comment["action_summaries"]: if action_summary["__typename"] == "LikeActionSummary": votes = action_summary["count"] commentObject = { "comment_author": comment["user"]["username"], "comment_text" : comment["body"], "timestamp" : comment["created_at"], "parent_comment_id" : parentId, "upvotes" : votes, "downvotes": 0 } commentList[comment["id"]] = commentObject try: commentReplies = self.__iterateComments(comment["replies"]["nodes"], comment["id"]) except KeyError: # There may be a limit of the nesting level of comments on wp commentReplies = {} commentList.update(commentReplies) return commentList
<|file_name|>WpApiParser.py<|end_file_name|><|fim▁begin|>from cse.util import Util from collections import OrderedDict from cse.pipeline import Handler class WpApiParser(Handler): def __init__(self): super() def parse(self, comments, url, assetId, parentId): data = self.__buildDataSkeleton(url, assetId) data["comments"] = self.__iterateComments(comments, parentId) return data def __buildDataSkeleton(self, url, assetId): return { "article_url" : url, "article_id" : assetId, "comments" : None } def __iterateComments(self, comments, parentId=None): commentList = OrderedDict() for comment in comments: votes = 0 for action_summary in comment["action_summaries"]: if action_summary["__typename"] == "LikeActionSummary": votes = action_summary["count"] commentObject = { "comment_author": comment["user"]["username"], "comment_text" : comment["body"], "timestamp" : comment["created_at"], "parent_comment_id" : parentId, "upvotes" : votes, "downvotes": 0 } commentList[comment["id"]] = commentObject try: commentReplies = self.__iterateComments(comment["replies"]["nodes"], comment["id"]) except KeyError: # There may be a limit of the nesting level of comments on wp commentReplies = {} commentList.update(commentReplies) return commentList # inherited from cse.pipeline.Handler def registeredAt(self, ctx): <|fim_middle|> def process(self, ctx, data): result = self.parse( comments=data["comments"], url=data["url"], assetId=data["assetId"], parentId=data["parentId"] ) ctx.write(result) <|fim▁end|>
pass
<|file_name|>WpApiParser.py<|end_file_name|><|fim▁begin|>from cse.util import Util from collections import OrderedDict from cse.pipeline import Handler class WpApiParser(Handler): def __init__(self): super() def parse(self, comments, url, assetId, parentId): data = self.__buildDataSkeleton(url, assetId) data["comments"] = self.__iterateComments(comments, parentId) return data def __buildDataSkeleton(self, url, assetId): return { "article_url" : url, "article_id" : assetId, "comments" : None } def __iterateComments(self, comments, parentId=None): commentList = OrderedDict() for comment in comments: votes = 0 for action_summary in comment["action_summaries"]: if action_summary["__typename"] == "LikeActionSummary": votes = action_summary["count"] commentObject = { "comment_author": comment["user"]["username"], "comment_text" : comment["body"], "timestamp" : comment["created_at"], "parent_comment_id" : parentId, "upvotes" : votes, "downvotes": 0 } commentList[comment["id"]] = commentObject try: commentReplies = self.__iterateComments(comment["replies"]["nodes"], comment["id"]) except KeyError: # There may be a limit of the nesting level of comments on wp commentReplies = {} commentList.update(commentReplies) return commentList # inherited from cse.pipeline.Handler def registeredAt(self, ctx): pass def process(self, ctx, data): <|fim_middle|> <|fim▁end|>
result = self.parse( comments=data["comments"], url=data["url"], assetId=data["assetId"], parentId=data["parentId"] ) ctx.write(result)
<|file_name|>WpApiParser.py<|end_file_name|><|fim▁begin|>from cse.util import Util from collections import OrderedDict from cse.pipeline import Handler class WpApiParser(Handler): def <|fim_middle|>(self): super() def parse(self, comments, url, assetId, parentId): data = self.__buildDataSkeleton(url, assetId) data["comments"] = self.__iterateComments(comments, parentId) return data def __buildDataSkeleton(self, url, assetId): return { "article_url" : url, "article_id" : assetId, "comments" : None } def __iterateComments(self, comments, parentId=None): commentList = OrderedDict() for comment in comments: votes = 0 for action_summary in comment["action_summaries"]: if action_summary["__typename"] == "LikeActionSummary": votes = action_summary["count"] commentObject = { "comment_author": comment["user"]["username"], "comment_text" : comment["body"], "timestamp" : comment["created_at"], "parent_comment_id" : parentId, "upvotes" : votes, "downvotes": 0 } commentList[comment["id"]] = commentObject try: commentReplies = self.__iterateComments(comment["replies"]["nodes"], comment["id"]) except KeyError: # There may be a limit of the nesting level of comments on wp commentReplies = {} commentList.update(commentReplies) return commentList # inherited from cse.pipeline.Handler def registeredAt(self, ctx): pass def process(self, ctx, data): result = self.parse( comments=data["comments"], url=data["url"], assetId=data["assetId"], parentId=data["parentId"] ) ctx.write(result) <|fim▁end|>
__init__
<|file_name|>WpApiParser.py<|end_file_name|><|fim▁begin|>from cse.util import Util from collections import OrderedDict from cse.pipeline import Handler class WpApiParser(Handler): def __init__(self): super() def <|fim_middle|>(self, comments, url, assetId, parentId): data = self.__buildDataSkeleton(url, assetId) data["comments"] = self.__iterateComments(comments, parentId) return data def __buildDataSkeleton(self, url, assetId): return { "article_url" : url, "article_id" : assetId, "comments" : None } def __iterateComments(self, comments, parentId=None): commentList = OrderedDict() for comment in comments: votes = 0 for action_summary in comment["action_summaries"]: if action_summary["__typename"] == "LikeActionSummary": votes = action_summary["count"] commentObject = { "comment_author": comment["user"]["username"], "comment_text" : comment["body"], "timestamp" : comment["created_at"], "parent_comment_id" : parentId, "upvotes" : votes, "downvotes": 0 } commentList[comment["id"]] = commentObject try: commentReplies = self.__iterateComments(comment["replies"]["nodes"], comment["id"]) except KeyError: # There may be a limit of the nesting level of comments on wp commentReplies = {} commentList.update(commentReplies) return commentList # inherited from cse.pipeline.Handler def registeredAt(self, ctx): pass def process(self, ctx, data): result = self.parse( comments=data["comments"], url=data["url"], assetId=data["assetId"], parentId=data["parentId"] ) ctx.write(result) <|fim▁end|>
parse
<|file_name|>WpApiParser.py<|end_file_name|><|fim▁begin|>from cse.util import Util from collections import OrderedDict from cse.pipeline import Handler class WpApiParser(Handler): def __init__(self): super() def parse(self, comments, url, assetId, parentId): data = self.__buildDataSkeleton(url, assetId) data["comments"] = self.__iterateComments(comments, parentId) return data def <|fim_middle|>(self, url, assetId): return { "article_url" : url, "article_id" : assetId, "comments" : None } def __iterateComments(self, comments, parentId=None): commentList = OrderedDict() for comment in comments: votes = 0 for action_summary in comment["action_summaries"]: if action_summary["__typename"] == "LikeActionSummary": votes = action_summary["count"] commentObject = { "comment_author": comment["user"]["username"], "comment_text" : comment["body"], "timestamp" : comment["created_at"], "parent_comment_id" : parentId, "upvotes" : votes, "downvotes": 0 } commentList[comment["id"]] = commentObject try: commentReplies = self.__iterateComments(comment["replies"]["nodes"], comment["id"]) except KeyError: # There may be a limit of the nesting level of comments on wp commentReplies = {} commentList.update(commentReplies) return commentList # inherited from cse.pipeline.Handler def registeredAt(self, ctx): pass def process(self, ctx, data): result = self.parse( comments=data["comments"], url=data["url"], assetId=data["assetId"], parentId=data["parentId"] ) ctx.write(result) <|fim▁end|>
__buildDataSkeleton
<|file_name|>WpApiParser.py<|end_file_name|><|fim▁begin|>from cse.util import Util from collections import OrderedDict from cse.pipeline import Handler class WpApiParser(Handler): def __init__(self): super() def parse(self, comments, url, assetId, parentId): data = self.__buildDataSkeleton(url, assetId) data["comments"] = self.__iterateComments(comments, parentId) return data def __buildDataSkeleton(self, url, assetId): return { "article_url" : url, "article_id" : assetId, "comments" : None } def <|fim_middle|>(self, comments, parentId=None): commentList = OrderedDict() for comment in comments: votes = 0 for action_summary in comment["action_summaries"]: if action_summary["__typename"] == "LikeActionSummary": votes = action_summary["count"] commentObject = { "comment_author": comment["user"]["username"], "comment_text" : comment["body"], "timestamp" : comment["created_at"], "parent_comment_id" : parentId, "upvotes" : votes, "downvotes": 0 } commentList[comment["id"]] = commentObject try: commentReplies = self.__iterateComments(comment["replies"]["nodes"], comment["id"]) except KeyError: # There may be a limit of the nesting level of comments on wp commentReplies = {} commentList.update(commentReplies) return commentList # inherited from cse.pipeline.Handler def registeredAt(self, ctx): pass def process(self, ctx, data): result = self.parse( comments=data["comments"], url=data["url"], assetId=data["assetId"], parentId=data["parentId"] ) ctx.write(result) <|fim▁end|>
__iterateComments
<|file_name|>WpApiParser.py<|end_file_name|><|fim▁begin|>from cse.util import Util from collections import OrderedDict from cse.pipeline import Handler class WpApiParser(Handler): def __init__(self): super() def parse(self, comments, url, assetId, parentId): data = self.__buildDataSkeleton(url, assetId) data["comments"] = self.__iterateComments(comments, parentId) return data def __buildDataSkeleton(self, url, assetId): return { "article_url" : url, "article_id" : assetId, "comments" : None } def __iterateComments(self, comments, parentId=None): commentList = OrderedDict() for comment in comments: votes = 0 for action_summary in comment["action_summaries"]: if action_summary["__typename"] == "LikeActionSummary": votes = action_summary["count"] commentObject = { "comment_author": comment["user"]["username"], "comment_text" : comment["body"], "timestamp" : comment["created_at"], "parent_comment_id" : parentId, "upvotes" : votes, "downvotes": 0 } commentList[comment["id"]] = commentObject try: commentReplies = self.__iterateComments(comment["replies"]["nodes"], comment["id"]) except KeyError: # There may be a limit of the nesting level of comments on wp commentReplies = {} commentList.update(commentReplies) return commentList # inherited from cse.pipeline.Handler def <|fim_middle|>(self, ctx): pass def process(self, ctx, data): result = self.parse( comments=data["comments"], url=data["url"], assetId=data["assetId"], parentId=data["parentId"] ) ctx.write(result) <|fim▁end|>
registeredAt
<|file_name|>WpApiParser.py<|end_file_name|><|fim▁begin|>from cse.util import Util from collections import OrderedDict from cse.pipeline import Handler class WpApiParser(Handler): def __init__(self): super() def parse(self, comments, url, assetId, parentId): data = self.__buildDataSkeleton(url, assetId) data["comments"] = self.__iterateComments(comments, parentId) return data def __buildDataSkeleton(self, url, assetId): return { "article_url" : url, "article_id" : assetId, "comments" : None } def __iterateComments(self, comments, parentId=None): commentList = OrderedDict() for comment in comments: votes = 0 for action_summary in comment["action_summaries"]: if action_summary["__typename"] == "LikeActionSummary": votes = action_summary["count"] commentObject = { "comment_author": comment["user"]["username"], "comment_text" : comment["body"], "timestamp" : comment["created_at"], "parent_comment_id" : parentId, "upvotes" : votes, "downvotes": 0 } commentList[comment["id"]] = commentObject try: commentReplies = self.__iterateComments(comment["replies"]["nodes"], comment["id"]) except KeyError: # There may be a limit of the nesting level of comments on wp commentReplies = {} commentList.update(commentReplies) return commentList # inherited from cse.pipeline.Handler def registeredAt(self, ctx): pass def <|fim_middle|>(self, ctx, data): result = self.parse( comments=data["comments"], url=data["url"], assetId=data["assetId"], parentId=data["parentId"] ) ctx.write(result) <|fim▁end|>
process
<|file_name|>servers.py<|end_file_name|><|fim▁begin|>from src.tools.dictionaries import PostLoadedDict # Utility class ################################################ class ServerImplementationDict(PostLoadedDict): <|fim_middle|> ################################################ class Server(): def __init__(self, shortname, loader): # Not preloaded # loaders must produce dictionaries (or an appropriate iterable) # with the required keys. # The reason for this is that code for certain servers need not be loaded # if it's not going to be used at all # It also prevents import loop collisions. global __ServerImplementationDict self.__data = ServerImplementationDict(loader) self.__shortname = shortname @property def shortname(self): # This is the only property provided from above return self.__shortname def __str__(self): return str(self.__shortname) # All other properties must come from canonical sources # provided by the server loader # CONSTANTS (STRINGS, BOOLEANS, INTS, ETC.) @property def name(self): return self.__data['str_name'] @property def internal_shortname(self): return self.__data['str_shortname'] @property def beta(self): return self.__data['bool_tester'] # CLASSES # 1- Credentials: @property def Auth(self): # I really don't know how to call this. return self.__data['cls_auth'] @property def auth_fields(self): return self.__data['list_authkeys'] # 2- Server Elements: @property def Player(self): return self.__data['cls_player'] @property def Tournament(self): return self.__data['cls_tournament']<|fim▁end|>
def __missing__(self, key): try: return super().__missing__(key) except KeyError: return NotImplemented
<|file_name|>servers.py<|end_file_name|><|fim▁begin|>from src.tools.dictionaries import PostLoadedDict # Utility class ################################################ class ServerImplementationDict(PostLoadedDict): def __missing__(self, key): <|fim_middle|> ################################################ class Server(): def __init__(self, shortname, loader): # Not preloaded # loaders must produce dictionaries (or an appropriate iterable) # with the required keys. # The reason for this is that code for certain servers need not be loaded # if it's not going to be used at all # It also prevents import loop collisions. global __ServerImplementationDict self.__data = ServerImplementationDict(loader) self.__shortname = shortname @property def shortname(self): # This is the only property provided from above return self.__shortname def __str__(self): return str(self.__shortname) # All other properties must come from canonical sources # provided by the server loader # CONSTANTS (STRINGS, BOOLEANS, INTS, ETC.) @property def name(self): return self.__data['str_name'] @property def internal_shortname(self): return self.__data['str_shortname'] @property def beta(self): return self.__data['bool_tester'] # CLASSES # 1- Credentials: @property def Auth(self): # I really don't know how to call this. return self.__data['cls_auth'] @property def auth_fields(self): return self.__data['list_authkeys'] # 2- Server Elements: @property def Player(self): return self.__data['cls_player'] @property def Tournament(self): return self.__data['cls_tournament']<|fim▁end|>
try: return super().__missing__(key) except KeyError: return NotImplemented
<|file_name|>servers.py<|end_file_name|><|fim▁begin|>from src.tools.dictionaries import PostLoadedDict # Utility class ################################################ class ServerImplementationDict(PostLoadedDict): def __missing__(self, key): try: return super().__missing__(key) except KeyError: return NotImplemented ################################################ class Server(): <|fim_middle|> <|fim▁end|>
def __init__(self, shortname, loader): # Not preloaded # loaders must produce dictionaries (or an appropriate iterable) # with the required keys. # The reason for this is that code for certain servers need not be loaded # if it's not going to be used at all # It also prevents import loop collisions. global __ServerImplementationDict self.__data = ServerImplementationDict(loader) self.__shortname = shortname @property def shortname(self): # This is the only property provided from above return self.__shortname def __str__(self): return str(self.__shortname) # All other properties must come from canonical sources # provided by the server loader # CONSTANTS (STRINGS, BOOLEANS, INTS, ETC.) @property def name(self): return self.__data['str_name'] @property def internal_shortname(self): return self.__data['str_shortname'] @property def beta(self): return self.__data['bool_tester'] # CLASSES # 1- Credentials: @property def Auth(self): # I really don't know how to call this. return self.__data['cls_auth'] @property def auth_fields(self): return self.__data['list_authkeys'] # 2- Server Elements: @property def Player(self): return self.__data['cls_player'] @property def Tournament(self): return self.__data['cls_tournament']
<|file_name|>servers.py<|end_file_name|><|fim▁begin|>from src.tools.dictionaries import PostLoadedDict # Utility class ################################################ class ServerImplementationDict(PostLoadedDict): def __missing__(self, key): try: return super().__missing__(key) except KeyError: return NotImplemented ################################################ class Server(): def __init__(self, shortname, loader): # Not preloaded # loaders must produce dictionaries (or an appropriate iterable) # with the required keys. # The reason for this is that code for certain servers need not be loaded # if it's not going to be used at all # It also prevents import loop collisions. <|fim_middle|> @property def shortname(self): # This is the only property provided from above return self.__shortname def __str__(self): return str(self.__shortname) # All other properties must come from canonical sources # provided by the server loader # CONSTANTS (STRINGS, BOOLEANS, INTS, ETC.) @property def name(self): return self.__data['str_name'] @property def internal_shortname(self): return self.__data['str_shortname'] @property def beta(self): return self.__data['bool_tester'] # CLASSES # 1- Credentials: @property def Auth(self): # I really don't know how to call this. return self.__data['cls_auth'] @property def auth_fields(self): return self.__data['list_authkeys'] # 2- Server Elements: @property def Player(self): return self.__data['cls_player'] @property def Tournament(self): return self.__data['cls_tournament']<|fim▁end|>
global __ServerImplementationDict self.__data = ServerImplementationDict(loader) self.__shortname = shortname
<|file_name|>servers.py<|end_file_name|><|fim▁begin|>from src.tools.dictionaries import PostLoadedDict # Utility class ################################################ class ServerImplementationDict(PostLoadedDict): def __missing__(self, key): try: return super().__missing__(key) except KeyError: return NotImplemented ################################################ class Server(): def __init__(self, shortname, loader): # Not preloaded # loaders must produce dictionaries (or an appropriate iterable) # with the required keys. # The reason for this is that code for certain servers need not be loaded # if it's not going to be used at all # It also prevents import loop collisions. global __ServerImplementationDict self.__data = ServerImplementationDict(loader) self.__shortname = shortname @property def shortname(self): # This is the only property provided from above <|fim_middle|> def __str__(self): return str(self.__shortname) # All other properties must come from canonical sources # provided by the server loader # CONSTANTS (STRINGS, BOOLEANS, INTS, ETC.) @property def name(self): return self.__data['str_name'] @property def internal_shortname(self): return self.__data['str_shortname'] @property def beta(self): return self.__data['bool_tester'] # CLASSES # 1- Credentials: @property def Auth(self): # I really don't know how to call this. return self.__data['cls_auth'] @property def auth_fields(self): return self.__data['list_authkeys'] # 2- Server Elements: @property def Player(self): return self.__data['cls_player'] @property def Tournament(self): return self.__data['cls_tournament']<|fim▁end|>
return self.__shortname
<|file_name|>servers.py<|end_file_name|><|fim▁begin|>from src.tools.dictionaries import PostLoadedDict # Utility class ################################################ class ServerImplementationDict(PostLoadedDict): def __missing__(self, key): try: return super().__missing__(key) except KeyError: return NotImplemented ################################################ class Server(): def __init__(self, shortname, loader): # Not preloaded # loaders must produce dictionaries (or an appropriate iterable) # with the required keys. # The reason for this is that code for certain servers need not be loaded # if it's not going to be used at all # It also prevents import loop collisions. global __ServerImplementationDict self.__data = ServerImplementationDict(loader) self.__shortname = shortname @property def shortname(self): # This is the only property provided from above return self.__shortname def __str__(self): <|fim_middle|> # All other properties must come from canonical sources # provided by the server loader # CONSTANTS (STRINGS, BOOLEANS, INTS, ETC.) @property def name(self): return self.__data['str_name'] @property def internal_shortname(self): return self.__data['str_shortname'] @property def beta(self): return self.__data['bool_tester'] # CLASSES # 1- Credentials: @property def Auth(self): # I really don't know how to call this. return self.__data['cls_auth'] @property def auth_fields(self): return self.__data['list_authkeys'] # 2- Server Elements: @property def Player(self): return self.__data['cls_player'] @property def Tournament(self): return self.__data['cls_tournament']<|fim▁end|>
return str(self.__shortname)
<|file_name|>servers.py<|end_file_name|><|fim▁begin|>from src.tools.dictionaries import PostLoadedDict # Utility class ################################################ class ServerImplementationDict(PostLoadedDict): def __missing__(self, key): try: return super().__missing__(key) except KeyError: return NotImplemented ################################################ class Server(): def __init__(self, shortname, loader): # Not preloaded # loaders must produce dictionaries (or an appropriate iterable) # with the required keys. # The reason for this is that code for certain servers need not be loaded # if it's not going to be used at all # It also prevents import loop collisions. global __ServerImplementationDict self.__data = ServerImplementationDict(loader) self.__shortname = shortname @property def shortname(self): # This is the only property provided from above return self.__shortname def __str__(self): return str(self.__shortname) # All other properties must come from canonical sources # provided by the server loader # CONSTANTS (STRINGS, BOOLEANS, INTS, ETC.) @property def name(self): <|fim_middle|> @property def internal_shortname(self): return self.__data['str_shortname'] @property def beta(self): return self.__data['bool_tester'] # CLASSES # 1- Credentials: @property def Auth(self): # I really don't know how to call this. return self.__data['cls_auth'] @property def auth_fields(self): return self.__data['list_authkeys'] # 2- Server Elements: @property def Player(self): return self.__data['cls_player'] @property def Tournament(self): return self.__data['cls_tournament']<|fim▁end|>
return self.__data['str_name']
<|file_name|>servers.py<|end_file_name|><|fim▁begin|>from src.tools.dictionaries import PostLoadedDict # Utility class ################################################ class ServerImplementationDict(PostLoadedDict): def __missing__(self, key): try: return super().__missing__(key) except KeyError: return NotImplemented ################################################ class Server(): def __init__(self, shortname, loader): # Not preloaded # loaders must produce dictionaries (or an appropriate iterable) # with the required keys. # The reason for this is that code for certain servers need not be loaded # if it's not going to be used at all # It also prevents import loop collisions. global __ServerImplementationDict self.__data = ServerImplementationDict(loader) self.__shortname = shortname @property def shortname(self): # This is the only property provided from above return self.__shortname def __str__(self): return str(self.__shortname) # All other properties must come from canonical sources # provided by the server loader # CONSTANTS (STRINGS, BOOLEANS, INTS, ETC.) @property def name(self): return self.__data['str_name'] @property def internal_shortname(self): <|fim_middle|> @property def beta(self): return self.__data['bool_tester'] # CLASSES # 1- Credentials: @property def Auth(self): # I really don't know how to call this. return self.__data['cls_auth'] @property def auth_fields(self): return self.__data['list_authkeys'] # 2- Server Elements: @property def Player(self): return self.__data['cls_player'] @property def Tournament(self): return self.__data['cls_tournament']<|fim▁end|>
return self.__data['str_shortname']
<|file_name|>servers.py<|end_file_name|><|fim▁begin|>from src.tools.dictionaries import PostLoadedDict # Utility class ################################################ class ServerImplementationDict(PostLoadedDict): def __missing__(self, key): try: return super().__missing__(key) except KeyError: return NotImplemented ################################################ class Server(): def __init__(self, shortname, loader): # Not preloaded # loaders must produce dictionaries (or an appropriate iterable) # with the required keys. # The reason for this is that code for certain servers need not be loaded # if it's not going to be used at all # It also prevents import loop collisions. global __ServerImplementationDict self.__data = ServerImplementationDict(loader) self.__shortname = shortname @property def shortname(self): # This is the only property provided from above return self.__shortname def __str__(self): return str(self.__shortname) # All other properties must come from canonical sources # provided by the server loader # CONSTANTS (STRINGS, BOOLEANS, INTS, ETC.) @property def name(self): return self.__data['str_name'] @property def internal_shortname(self): return self.__data['str_shortname'] @property def beta(self): <|fim_middle|> # CLASSES # 1- Credentials: @property def Auth(self): # I really don't know how to call this. return self.__data['cls_auth'] @property def auth_fields(self): return self.__data['list_authkeys'] # 2- Server Elements: @property def Player(self): return self.__data['cls_player'] @property def Tournament(self): return self.__data['cls_tournament']<|fim▁end|>
return self.__data['bool_tester']
<|file_name|>servers.py<|end_file_name|><|fim▁begin|>from src.tools.dictionaries import PostLoadedDict # Utility class ################################################ class ServerImplementationDict(PostLoadedDict): def __missing__(self, key): try: return super().__missing__(key) except KeyError: return NotImplemented ################################################ class Server(): def __init__(self, shortname, loader): # Not preloaded # loaders must produce dictionaries (or an appropriate iterable) # with the required keys. # The reason for this is that code for certain servers need not be loaded # if it's not going to be used at all # It also prevents import loop collisions. global __ServerImplementationDict self.__data = ServerImplementationDict(loader) self.__shortname = shortname @property def shortname(self): # This is the only property provided from above return self.__shortname def __str__(self): return str(self.__shortname) # All other properties must come from canonical sources # provided by the server loader # CONSTANTS (STRINGS, BOOLEANS, INTS, ETC.) @property def name(self): return self.__data['str_name'] @property def internal_shortname(self): return self.__data['str_shortname'] @property def beta(self): return self.__data['bool_tester'] # CLASSES # 1- Credentials: @property def Auth(self): # I really don't know how to call this. <|fim_middle|> @property def auth_fields(self): return self.__data['list_authkeys'] # 2- Server Elements: @property def Player(self): return self.__data['cls_player'] @property def Tournament(self): return self.__data['cls_tournament']<|fim▁end|>
return self.__data['cls_auth']
<|file_name|>servers.py<|end_file_name|><|fim▁begin|>from src.tools.dictionaries import PostLoadedDict # Utility class ################################################ class ServerImplementationDict(PostLoadedDict): def __missing__(self, key): try: return super().__missing__(key) except KeyError: return NotImplemented ################################################ class Server(): def __init__(self, shortname, loader): # Not preloaded # loaders must produce dictionaries (or an appropriate iterable) # with the required keys. # The reason for this is that code for certain servers need not be loaded # if it's not going to be used at all # It also prevents import loop collisions. global __ServerImplementationDict self.__data = ServerImplementationDict(loader) self.__shortname = shortname @property def shortname(self): # This is the only property provided from above return self.__shortname def __str__(self): return str(self.__shortname) # All other properties must come from canonical sources # provided by the server loader # CONSTANTS (STRINGS, BOOLEANS, INTS, ETC.) @property def name(self): return self.__data['str_name'] @property def internal_shortname(self): return self.__data['str_shortname'] @property def beta(self): return self.__data['bool_tester'] # CLASSES # 1- Credentials: @property def Auth(self): # I really don't know how to call this. return self.__data['cls_auth'] @property def auth_fields(self): <|fim_middle|> # 2- Server Elements: @property def Player(self): return self.__data['cls_player'] @property def Tournament(self): return self.__data['cls_tournament']<|fim▁end|>
return self.__data['list_authkeys']
<|file_name|>servers.py<|end_file_name|><|fim▁begin|>from src.tools.dictionaries import PostLoadedDict # Utility class ################################################ class ServerImplementationDict(PostLoadedDict): def __missing__(self, key): try: return super().__missing__(key) except KeyError: return NotImplemented ################################################ class Server(): def __init__(self, shortname, loader): # Not preloaded # loaders must produce dictionaries (or an appropriate iterable) # with the required keys. # The reason for this is that code for certain servers need not be loaded # if it's not going to be used at all # It also prevents import loop collisions. global __ServerImplementationDict self.__data = ServerImplementationDict(loader) self.__shortname = shortname @property def shortname(self): # This is the only property provided from above return self.__shortname def __str__(self): return str(self.__shortname) # All other properties must come from canonical sources # provided by the server loader # CONSTANTS (STRINGS, BOOLEANS, INTS, ETC.) @property def name(self): return self.__data['str_name'] @property def internal_shortname(self): return self.__data['str_shortname'] @property def beta(self): return self.__data['bool_tester'] # CLASSES # 1- Credentials: @property def Auth(self): # I really don't know how to call this. return self.__data['cls_auth'] @property def auth_fields(self): return self.__data['list_authkeys'] # 2- Server Elements: @property def Player(self): <|fim_middle|> @property def Tournament(self): return self.__data['cls_tournament']<|fim▁end|>
return self.__data['cls_player']
<|file_name|>servers.py<|end_file_name|><|fim▁begin|>from src.tools.dictionaries import PostLoadedDict # Utility class ################################################ class ServerImplementationDict(PostLoadedDict): def __missing__(self, key): try: return super().__missing__(key) except KeyError: return NotImplemented ################################################ class Server(): def __init__(self, shortname, loader): # Not preloaded # loaders must produce dictionaries (or an appropriate iterable) # with the required keys. # The reason for this is that code for certain servers need not be loaded # if it's not going to be used at all # It also prevents import loop collisions. global __ServerImplementationDict self.__data = ServerImplementationDict(loader) self.__shortname = shortname @property def shortname(self): # This is the only property provided from above return self.__shortname def __str__(self): return str(self.__shortname) # All other properties must come from canonical sources # provided by the server loader # CONSTANTS (STRINGS, BOOLEANS, INTS, ETC.) @property def name(self): return self.__data['str_name'] @property def internal_shortname(self): return self.__data['str_shortname'] @property def beta(self): return self.__data['bool_tester'] # CLASSES # 1- Credentials: @property def Auth(self): # I really don't know how to call this. return self.__data['cls_auth'] @property def auth_fields(self): return self.__data['list_authkeys'] # 2- Server Elements: @property def Player(self): return self.__data['cls_player'] @property def Tournament(self): <|fim_middle|> <|fim▁end|>
return self.__data['cls_tournament']
<|file_name|>servers.py<|end_file_name|><|fim▁begin|>from src.tools.dictionaries import PostLoadedDict # Utility class ################################################ class ServerImplementationDict(PostLoadedDict): def __missing__(self, key): try: return super().__missing__(key) except KeyError: return NotImplemented ################################################ class Server(): def __init__(self, shortname, loader): # Not preloaded # loaders must produce dictionaries (or an appropriate iterable) # with the required keys. # The reason for this is that code for certain servers need not be loaded # if it's not going to be used at all # It also prevents import loop collisions. global __ServerImplementationDict self.__data = ServerImplementationDict(loader) self.__shortname = shortname @property def shortname(self): # This is the only property provided from above return self.__shortname def __str__(self): return str(self.__shortname) # All other properties must come from canonical sources # provided by the server loader # CONSTANTS (STRINGS, BOOLEANS, INTS, ETC.) @property def name(self): return self.__data['str_name'] @property def internal_shortname(self): return self.__data['str_shortname'] @property def beta(self): return self.__data['bool_tester'] # CLASSES # 1- Credentials: @property def Auth(self): # I really don't know how to call this.<|fim▁hole|> # 2- Server Elements: @property def Player(self): return self.__data['cls_player'] @property def Tournament(self): return self.__data['cls_tournament']<|fim▁end|>
return self.__data['cls_auth'] @property def auth_fields(self): return self.__data['list_authkeys']
<|file_name|>servers.py<|end_file_name|><|fim▁begin|>from src.tools.dictionaries import PostLoadedDict # Utility class ################################################ class ServerImplementationDict(PostLoadedDict): def <|fim_middle|>(self, key): try: return super().__missing__(key) except KeyError: return NotImplemented ################################################ class Server(): def __init__(self, shortname, loader): # Not preloaded # loaders must produce dictionaries (or an appropriate iterable) # with the required keys. # The reason for this is that code for certain servers need not be loaded # if it's not going to be used at all # It also prevents import loop collisions. global __ServerImplementationDict self.__data = ServerImplementationDict(loader) self.__shortname = shortname @property def shortname(self): # This is the only property provided from above return self.__shortname def __str__(self): return str(self.__shortname) # All other properties must come from canonical sources # provided by the server loader # CONSTANTS (STRINGS, BOOLEANS, INTS, ETC.) @property def name(self): return self.__data['str_name'] @property def internal_shortname(self): return self.__data['str_shortname'] @property def beta(self): return self.__data['bool_tester'] # CLASSES # 1- Credentials: @property def Auth(self): # I really don't know how to call this. return self.__data['cls_auth'] @property def auth_fields(self): return self.__data['list_authkeys'] # 2- Server Elements: @property def Player(self): return self.__data['cls_player'] @property def Tournament(self): return self.__data['cls_tournament']<|fim▁end|>
__missing__
<|file_name|>servers.py<|end_file_name|><|fim▁begin|>from src.tools.dictionaries import PostLoadedDict # Utility class ################################################ class ServerImplementationDict(PostLoadedDict): def __missing__(self, key): try: return super().__missing__(key) except KeyError: return NotImplemented ################################################ class Server(): def <|fim_middle|>(self, shortname, loader): # Not preloaded # loaders must produce dictionaries (or an appropriate iterable) # with the required keys. # The reason for this is that code for certain servers need not be loaded # if it's not going to be used at all # It also prevents import loop collisions. global __ServerImplementationDict self.__data = ServerImplementationDict(loader) self.__shortname = shortname @property def shortname(self): # This is the only property provided from above return self.__shortname def __str__(self): return str(self.__shortname) # All other properties must come from canonical sources # provided by the server loader # CONSTANTS (STRINGS, BOOLEANS, INTS, ETC.) @property def name(self): return self.__data['str_name'] @property def internal_shortname(self): return self.__data['str_shortname'] @property def beta(self): return self.__data['bool_tester'] # CLASSES # 1- Credentials: @property def Auth(self): # I really don't know how to call this. return self.__data['cls_auth'] @property def auth_fields(self): return self.__data['list_authkeys'] # 2- Server Elements: @property def Player(self): return self.__data['cls_player'] @property def Tournament(self): return self.__data['cls_tournament']<|fim▁end|>
__init__
<|file_name|>servers.py<|end_file_name|><|fim▁begin|>from src.tools.dictionaries import PostLoadedDict # Utility class ################################################ class ServerImplementationDict(PostLoadedDict): def __missing__(self, key): try: return super().__missing__(key) except KeyError: return NotImplemented ################################################ class Server(): def __init__(self, shortname, loader): # Not preloaded # loaders must produce dictionaries (or an appropriate iterable) # with the required keys. # The reason for this is that code for certain servers need not be loaded # if it's not going to be used at all # It also prevents import loop collisions. global __ServerImplementationDict self.__data = ServerImplementationDict(loader) self.__shortname = shortname @property def <|fim_middle|>(self): # This is the only property provided from above return self.__shortname def __str__(self): return str(self.__shortname) # All other properties must come from canonical sources # provided by the server loader # CONSTANTS (STRINGS, BOOLEANS, INTS, ETC.) @property def name(self): return self.__data['str_name'] @property def internal_shortname(self): return self.__data['str_shortname'] @property def beta(self): return self.__data['bool_tester'] # CLASSES # 1- Credentials: @property def Auth(self): # I really don't know how to call this. return self.__data['cls_auth'] @property def auth_fields(self): return self.__data['list_authkeys'] # 2- Server Elements: @property def Player(self): return self.__data['cls_player'] @property def Tournament(self): return self.__data['cls_tournament']<|fim▁end|>
shortname
<|file_name|>servers.py<|end_file_name|><|fim▁begin|>from src.tools.dictionaries import PostLoadedDict # Utility class ################################################ class ServerImplementationDict(PostLoadedDict): def __missing__(self, key): try: return super().__missing__(key) except KeyError: return NotImplemented ################################################ class Server(): def __init__(self, shortname, loader): # Not preloaded # loaders must produce dictionaries (or an appropriate iterable) # with the required keys. # The reason for this is that code for certain servers need not be loaded # if it's not going to be used at all # It also prevents import loop collisions. global __ServerImplementationDict self.__data = ServerImplementationDict(loader) self.__shortname = shortname @property def shortname(self): # This is the only property provided from above return self.__shortname def <|fim_middle|>(self): return str(self.__shortname) # All other properties must come from canonical sources # provided by the server loader # CONSTANTS (STRINGS, BOOLEANS, INTS, ETC.) @property def name(self): return self.__data['str_name'] @property def internal_shortname(self): return self.__data['str_shortname'] @property def beta(self): return self.__data['bool_tester'] # CLASSES # 1- Credentials: @property def Auth(self): # I really don't know how to call this. return self.__data['cls_auth'] @property def auth_fields(self): return self.__data['list_authkeys'] # 2- Server Elements: @property def Player(self): return self.__data['cls_player'] @property def Tournament(self): return self.__data['cls_tournament']<|fim▁end|>
__str__
<|file_name|>servers.py<|end_file_name|><|fim▁begin|>from src.tools.dictionaries import PostLoadedDict # Utility class ################################################ class ServerImplementationDict(PostLoadedDict): def __missing__(self, key): try: return super().__missing__(key) except KeyError: return NotImplemented ################################################ class Server(): def __init__(self, shortname, loader): # Not preloaded # loaders must produce dictionaries (or an appropriate iterable) # with the required keys. # The reason for this is that code for certain servers need not be loaded # if it's not going to be used at all # It also prevents import loop collisions. global __ServerImplementationDict self.__data = ServerImplementationDict(loader) self.__shortname = shortname @property def shortname(self): # This is the only property provided from above return self.__shortname def __str__(self): return str(self.__shortname) # All other properties must come from canonical sources # provided by the server loader # CONSTANTS (STRINGS, BOOLEANS, INTS, ETC.) @property def <|fim_middle|>(self): return self.__data['str_name'] @property def internal_shortname(self): return self.__data['str_shortname'] @property def beta(self): return self.__data['bool_tester'] # CLASSES # 1- Credentials: @property def Auth(self): # I really don't know how to call this. return self.__data['cls_auth'] @property def auth_fields(self): return self.__data['list_authkeys'] # 2- Server Elements: @property def Player(self): return self.__data['cls_player'] @property def Tournament(self): return self.__data['cls_tournament']<|fim▁end|>
name
<|file_name|>servers.py<|end_file_name|><|fim▁begin|>from src.tools.dictionaries import PostLoadedDict # Utility class ################################################ class ServerImplementationDict(PostLoadedDict): def __missing__(self, key): try: return super().__missing__(key) except KeyError: return NotImplemented ################################################ class Server(): def __init__(self, shortname, loader): # Not preloaded # loaders must produce dictionaries (or an appropriate iterable) # with the required keys. # The reason for this is that code for certain servers need not be loaded # if it's not going to be used at all # It also prevents import loop collisions. global __ServerImplementationDict self.__data = ServerImplementationDict(loader) self.__shortname = shortname @property def shortname(self): # This is the only property provided from above return self.__shortname def __str__(self): return str(self.__shortname) # All other properties must come from canonical sources # provided by the server loader # CONSTANTS (STRINGS, BOOLEANS, INTS, ETC.) @property def name(self): return self.__data['str_name'] @property def <|fim_middle|>(self): return self.__data['str_shortname'] @property def beta(self): return self.__data['bool_tester'] # CLASSES # 1- Credentials: @property def Auth(self): # I really don't know how to call this. return self.__data['cls_auth'] @property def auth_fields(self): return self.__data['list_authkeys'] # 2- Server Elements: @property def Player(self): return self.__data['cls_player'] @property def Tournament(self): return self.__data['cls_tournament']<|fim▁end|>
internal_shortname
<|file_name|>servers.py<|end_file_name|><|fim▁begin|>from src.tools.dictionaries import PostLoadedDict # Utility class ################################################ class ServerImplementationDict(PostLoadedDict): def __missing__(self, key): try: return super().__missing__(key) except KeyError: return NotImplemented ################################################ class Server(): def __init__(self, shortname, loader): # Not preloaded # loaders must produce dictionaries (or an appropriate iterable) # with the required keys. # The reason for this is that code for certain servers need not be loaded # if it's not going to be used at all # It also prevents import loop collisions. global __ServerImplementationDict self.__data = ServerImplementationDict(loader) self.__shortname = shortname @property def shortname(self): # This is the only property provided from above return self.__shortname def __str__(self): return str(self.__shortname) # All other properties must come from canonical sources # provided by the server loader # CONSTANTS (STRINGS, BOOLEANS, INTS, ETC.) @property def name(self): return self.__data['str_name'] @property def internal_shortname(self): return self.__data['str_shortname'] @property def <|fim_middle|>(self): return self.__data['bool_tester'] # CLASSES # 1- Credentials: @property def Auth(self): # I really don't know how to call this. return self.__data['cls_auth'] @property def auth_fields(self): return self.__data['list_authkeys'] # 2- Server Elements: @property def Player(self): return self.__data['cls_player'] @property def Tournament(self): return self.__data['cls_tournament']<|fim▁end|>
beta
<|file_name|>servers.py<|end_file_name|><|fim▁begin|>from src.tools.dictionaries import PostLoadedDict # Utility class ################################################ class ServerImplementationDict(PostLoadedDict): def __missing__(self, key): try: return super().__missing__(key) except KeyError: return NotImplemented ################################################ class Server(): def __init__(self, shortname, loader): # Not preloaded # loaders must produce dictionaries (or an appropriate iterable) # with the required keys. # The reason for this is that code for certain servers need not be loaded # if it's not going to be used at all # It also prevents import loop collisions. global __ServerImplementationDict self.__data = ServerImplementationDict(loader) self.__shortname = shortname @property def shortname(self): # This is the only property provided from above return self.__shortname def __str__(self): return str(self.__shortname) # All other properties must come from canonical sources # provided by the server loader # CONSTANTS (STRINGS, BOOLEANS, INTS, ETC.) @property def name(self): return self.__data['str_name'] @property def internal_shortname(self): return self.__data['str_shortname'] @property def beta(self): return self.__data['bool_tester'] # CLASSES # 1- Credentials: @property def <|fim_middle|>(self): # I really don't know how to call this. return self.__data['cls_auth'] @property def auth_fields(self): return self.__data['list_authkeys'] # 2- Server Elements: @property def Player(self): return self.__data['cls_player'] @property def Tournament(self): return self.__data['cls_tournament']<|fim▁end|>
Auth
<|file_name|>servers.py<|end_file_name|><|fim▁begin|>from src.tools.dictionaries import PostLoadedDict # Utility class ################################################ class ServerImplementationDict(PostLoadedDict): def __missing__(self, key): try: return super().__missing__(key) except KeyError: return NotImplemented ################################################ class Server(): def __init__(self, shortname, loader): # Not preloaded # loaders must produce dictionaries (or an appropriate iterable) # with the required keys. # The reason for this is that code for certain servers need not be loaded # if it's not going to be used at all # It also prevents import loop collisions. global __ServerImplementationDict self.__data = ServerImplementationDict(loader) self.__shortname = shortname @property def shortname(self): # This is the only property provided from above return self.__shortname def __str__(self): return str(self.__shortname) # All other properties must come from canonical sources # provided by the server loader # CONSTANTS (STRINGS, BOOLEANS, INTS, ETC.) @property def name(self): return self.__data['str_name'] @property def internal_shortname(self): return self.__data['str_shortname'] @property def beta(self): return self.__data['bool_tester'] # CLASSES # 1- Credentials: @property def Auth(self): # I really don't know how to call this. return self.__data['cls_auth'] @property def <|fim_middle|>(self): return self.__data['list_authkeys'] # 2- Server Elements: @property def Player(self): return self.__data['cls_player'] @property def Tournament(self): return self.__data['cls_tournament']<|fim▁end|>
auth_fields
<|file_name|>servers.py<|end_file_name|><|fim▁begin|>from src.tools.dictionaries import PostLoadedDict # Utility class ################################################ class ServerImplementationDict(PostLoadedDict): def __missing__(self, key): try: return super().__missing__(key) except KeyError: return NotImplemented ################################################ class Server(): def __init__(self, shortname, loader): # Not preloaded # loaders must produce dictionaries (or an appropriate iterable) # with the required keys. # The reason for this is that code for certain servers need not be loaded # if it's not going to be used at all # It also prevents import loop collisions. global __ServerImplementationDict self.__data = ServerImplementationDict(loader) self.__shortname = shortname @property def shortname(self): # This is the only property provided from above return self.__shortname def __str__(self): return str(self.__shortname) # All other properties must come from canonical sources # provided by the server loader # CONSTANTS (STRINGS, BOOLEANS, INTS, ETC.) @property def name(self): return self.__data['str_name'] @property def internal_shortname(self): return self.__data['str_shortname'] @property def beta(self): return self.__data['bool_tester'] # CLASSES # 1- Credentials: @property def Auth(self): # I really don't know how to call this. return self.__data['cls_auth'] @property def auth_fields(self): return self.__data['list_authkeys'] # 2- Server Elements: @property def <|fim_middle|>(self): return self.__data['cls_player'] @property def Tournament(self): return self.__data['cls_tournament']<|fim▁end|>
Player
<|file_name|>servers.py<|end_file_name|><|fim▁begin|>from src.tools.dictionaries import PostLoadedDict # Utility class ################################################ class ServerImplementationDict(PostLoadedDict): def __missing__(self, key): try: return super().__missing__(key) except KeyError: return NotImplemented ################################################ class Server(): def __init__(self, shortname, loader): # Not preloaded # loaders must produce dictionaries (or an appropriate iterable) # with the required keys. # The reason for this is that code for certain servers need not be loaded # if it's not going to be used at all # It also prevents import loop collisions. global __ServerImplementationDict self.__data = ServerImplementationDict(loader) self.__shortname = shortname @property def shortname(self): # This is the only property provided from above return self.__shortname def __str__(self): return str(self.__shortname) # All other properties must come from canonical sources # provided by the server loader # CONSTANTS (STRINGS, BOOLEANS, INTS, ETC.) @property def name(self): return self.__data['str_name'] @property def internal_shortname(self): return self.__data['str_shortname'] @property def beta(self): return self.__data['bool_tester'] # CLASSES # 1- Credentials: @property def Auth(self): # I really don't know how to call this. return self.__data['cls_auth'] @property def auth_fields(self): return self.__data['list_authkeys'] # 2- Server Elements: @property def Player(self): return self.__data['cls_player'] @property def <|fim_middle|>(self): return self.__data['cls_tournament']<|fim▁end|>
Tournament
<|file_name|>plugin.py<|end_file_name|><|fim▁begin|># @file plugin.py # # Connect Zen Coding to Pluma. # # Adapted to pluma by Joao Manoel ([email protected]) # # Original Author Franck Marcia ([email protected]) # import pluma, gobject, gtk, os from zen_editor import ZenEditor zencoding_ui_str = """ <ui> <menubar name="MenuBar"> <menu name="EditMenu" action="Edit"> <placeholder name="EditOps_5"> <menu action="ZenCodingMenuAction"> <menuitem name="ZenCodingExpand" action="ZenCodingExpandAction"/> <menuitem name="ZenCodingExpandW" action="ZenCodingExpandWAction"/> <menuitem name="ZenCodingWrap" action="ZenCodingWrapAction"/> <separator/> <menuitem name="ZenCodingInward" action="ZenCodingInwardAction"/> <menuitem name="ZenCodingOutward" action="ZenCodingOutwardAction"/> <menuitem name="ZenCodingMerge" action="ZenCodingMergeAction"/> <separator/> <menuitem name="ZenCodingPrev" action="ZenCodingPrevAction"/> <menuitem name="ZenCodingNext" action="ZenCodingNextAction"/> <separator/> <menuitem name="ZenCodingRemove" action="ZenCodingRemoveAction"/> <menuitem name="ZenCodingSplit" action="ZenCodingSplitAction"/> <menuitem name="ZenCodingComment" action="ZenCodingCommentAction"/> </menu> </placeholder> </menu> </menubar> </ui> """ class ZenCodingPlugin(pluma.Plugin): <|fim_middle|> <|fim▁end|>
"""A Pluma plugin to implement Zen Coding's HTML and CSS shorthand expander.""" def activate(self, window): actions = [ ('ZenCodingMenuAction', None, '_Zen Coding', None, "Zen Coding tools", None), ('ZenCodingExpandAction', None, '_Expand abbreviation', '<Ctrl>E', "Expand abbreviation to raw HTML/CSS", self.expand_abbreviation), ('ZenCodingExpandWAction', None, 'E_xpand dynamic abbreviation...', '<Ctrl><Alt>E', "Dynamically expand abbreviation as you type", self.expand_with_abbreviation), ('ZenCodingWrapAction', None, '_Wrap with abbreviation...', '<Ctrl><Shift>E', "Wrap with code expanded from abbreviation", self.wrap_with_abbreviation), ('ZenCodingInwardAction', None, 'Balance tag _inward', '<Ctrl><Alt>I', "Select inner tag's content", self.match_pair_inward), ('ZenCodingOutwardAction', None, 'Balance tag _outward', '<Ctrl><Alt>O', "Select outer tag's content", self.match_pair_outward), ('ZenCodingMergeAction', None, '_Merge lines', '<Ctrl><Alt>M', "Merge all lines of the current selection", self.merge_lines), ('ZenCodingPrevAction', None, '_Previous edit point', '<Alt>Left', "Place the cursor at the previous edit point", self.prev_edit_point), ('ZenCodingNextAction', None, '_Next edit point', '<Alt>Right', "Place the cursor at the next edit point", self.next_edit_point), ('ZenCodingRemoveAction', None, '_Remove tag', '<Ctrl><Alt>R', "Remove a tag", self.remove_tag), ('ZenCodingSplitAction', None, 'Split or _join tag', '<Ctrl><Alt>J', "Toggle between single and double tag", self.split_join_tag), ('ZenCodingCommentAction', None, 'Toggle _comment', '<Ctrl><Alt>C', "Toggle an XML or HTML comment", self.toggle_comment) ] windowdata = dict() window.set_data("ZenCodingPluginDataKey", windowdata) windowdata["action_group"] = gtk.ActionGroup("PlumaZenCodingPluginActions") windowdata["action_group"].add_actions(actions, window) manager = window.get_ui_manager() manager.insert_action_group(windowdata["action_group"], -1) windowdata["ui_id"] = manager.add_ui_from_string(zencoding_ui_str) window.set_data("ZenCodingPluginInfo", windowdata) self.editor = ZenEditor() error = self.editor.get_user_settings_error() if error: md = gtk.MessageDialog(window, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE, "There is an error in user settings:") message = "{0} on line {1} at character {2}\n\nUser settings will not be available." md.set_title("Zen Coding error") md.format_secondary_text(message.format(error['msg'], error['lineno'], error['offset'])) md.run() md.destroy() def deactivate(self, window): windowdata = window.get_data("ZenCodingPluginDataKey") manager = window.get_ui_manager() manager.remove_ui(windowdata["ui_id"]) manager.remove_action_group(windowdata["action_group"]) def update_ui(self, window): view = window.get_active_view() windowdata = window.get_data("ZenCodingPluginDataKey") windowdata["action_group"].set_sensitive(bool(view and view.get_editable())) def expand_abbreviation(self, action, window): self.editor.expand_abbreviation(window) def expand_with_abbreviation(self, action, window): self.editor.expand_with_abbreviation(window) def wrap_with_abbreviation(self, action, window): self.editor.wrap_with_abbreviation(window) def match_pair_inward(self, action, window): self.editor.match_pair_inward(window) def match_pair_outward(self, action, window): self.editor.match_pair_outward(window) def merge_lines(self, action, window): self.editor.merge_lines(window) def prev_edit_point(self, action, window): self.editor.prev_edit_point(window) def next_edit_point(self, action, window): self.editor.next_edit_point(window) def remove_tag(self, action, window): self.editor.remove_tag(window) def split_join_tag(self, action, window): self.editor.split_join_tag(window) def toggle_comment(self, action, window): self.editor.toggle_comment(window)
<|file_name|>plugin.py<|end_file_name|><|fim▁begin|># @file plugin.py # # Connect Zen Coding to Pluma. # # Adapted to pluma by Joao Manoel ([email protected]) # # Original Author Franck Marcia ([email protected]) # import pluma, gobject, gtk, os from zen_editor import ZenEditor zencoding_ui_str = """ <ui> <menubar name="MenuBar"> <menu name="EditMenu" action="Edit"> <placeholder name="EditOps_5"> <menu action="ZenCodingMenuAction"> <menuitem name="ZenCodingExpand" action="ZenCodingExpandAction"/> <menuitem name="ZenCodingExpandW" action="ZenCodingExpandWAction"/> <menuitem name="ZenCodingWrap" action="ZenCodingWrapAction"/> <separator/> <menuitem name="ZenCodingInward" action="ZenCodingInwardAction"/> <menuitem name="ZenCodingOutward" action="ZenCodingOutwardAction"/> <menuitem name="ZenCodingMerge" action="ZenCodingMergeAction"/> <separator/> <menuitem name="ZenCodingPrev" action="ZenCodingPrevAction"/> <menuitem name="ZenCodingNext" action="ZenCodingNextAction"/> <separator/> <menuitem name="ZenCodingRemove" action="ZenCodingRemoveAction"/> <menuitem name="ZenCodingSplit" action="ZenCodingSplitAction"/> <menuitem name="ZenCodingComment" action="ZenCodingCommentAction"/> </menu> </placeholder> </menu> </menubar> </ui> """ class ZenCodingPlugin(pluma.Plugin): """A Pluma plugin to implement Zen Coding's HTML and CSS shorthand expander.""" def activate(self, window): <|fim_middle|> def deactivate(self, window): windowdata = window.get_data("ZenCodingPluginDataKey") manager = window.get_ui_manager() manager.remove_ui(windowdata["ui_id"]) manager.remove_action_group(windowdata["action_group"]) def update_ui(self, window): view = window.get_active_view() windowdata = window.get_data("ZenCodingPluginDataKey") windowdata["action_group"].set_sensitive(bool(view and view.get_editable())) def expand_abbreviation(self, action, window): self.editor.expand_abbreviation(window) def expand_with_abbreviation(self, action, window): self.editor.expand_with_abbreviation(window) def wrap_with_abbreviation(self, action, window): self.editor.wrap_with_abbreviation(window) def match_pair_inward(self, action, window): self.editor.match_pair_inward(window) def match_pair_outward(self, action, window): self.editor.match_pair_outward(window) def merge_lines(self, action, window): self.editor.merge_lines(window) def prev_edit_point(self, action, window): self.editor.prev_edit_point(window) def next_edit_point(self, action, window): self.editor.next_edit_point(window) def remove_tag(self, action, window): self.editor.remove_tag(window) def split_join_tag(self, action, window): self.editor.split_join_tag(window) def toggle_comment(self, action, window): self.editor.toggle_comment(window) <|fim▁end|>
actions = [ ('ZenCodingMenuAction', None, '_Zen Coding', None, "Zen Coding tools", None), ('ZenCodingExpandAction', None, '_Expand abbreviation', '<Ctrl>E', "Expand abbreviation to raw HTML/CSS", self.expand_abbreviation), ('ZenCodingExpandWAction', None, 'E_xpand dynamic abbreviation...', '<Ctrl><Alt>E', "Dynamically expand abbreviation as you type", self.expand_with_abbreviation), ('ZenCodingWrapAction', None, '_Wrap with abbreviation...', '<Ctrl><Shift>E', "Wrap with code expanded from abbreviation", self.wrap_with_abbreviation), ('ZenCodingInwardAction', None, 'Balance tag _inward', '<Ctrl><Alt>I', "Select inner tag's content", self.match_pair_inward), ('ZenCodingOutwardAction', None, 'Balance tag _outward', '<Ctrl><Alt>O', "Select outer tag's content", self.match_pair_outward), ('ZenCodingMergeAction', None, '_Merge lines', '<Ctrl><Alt>M', "Merge all lines of the current selection", self.merge_lines), ('ZenCodingPrevAction', None, '_Previous edit point', '<Alt>Left', "Place the cursor at the previous edit point", self.prev_edit_point), ('ZenCodingNextAction', None, '_Next edit point', '<Alt>Right', "Place the cursor at the next edit point", self.next_edit_point), ('ZenCodingRemoveAction', None, '_Remove tag', '<Ctrl><Alt>R', "Remove a tag", self.remove_tag), ('ZenCodingSplitAction', None, 'Split or _join tag', '<Ctrl><Alt>J', "Toggle between single and double tag", self.split_join_tag), ('ZenCodingCommentAction', None, 'Toggle _comment', '<Ctrl><Alt>C', "Toggle an XML or HTML comment", self.toggle_comment) ] windowdata = dict() window.set_data("ZenCodingPluginDataKey", windowdata) windowdata["action_group"] = gtk.ActionGroup("PlumaZenCodingPluginActions") windowdata["action_group"].add_actions(actions, window) manager = window.get_ui_manager() manager.insert_action_group(windowdata["action_group"], -1) windowdata["ui_id"] = manager.add_ui_from_string(zencoding_ui_str) window.set_data("ZenCodingPluginInfo", windowdata) self.editor = ZenEditor() error = self.editor.get_user_settings_error() if error: md = gtk.MessageDialog(window, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE, "There is an error in user settings:") message = "{0} on line {1} at character {2}\n\nUser settings will not be available." md.set_title("Zen Coding error") md.format_secondary_text(message.format(error['msg'], error['lineno'], error['offset'])) md.run() md.destroy()
<|file_name|>plugin.py<|end_file_name|><|fim▁begin|># @file plugin.py # # Connect Zen Coding to Pluma. # # Adapted to pluma by Joao Manoel ([email protected]) # # Original Author Franck Marcia ([email protected]) # import pluma, gobject, gtk, os from zen_editor import ZenEditor zencoding_ui_str = """ <ui> <menubar name="MenuBar"> <menu name="EditMenu" action="Edit"> <placeholder name="EditOps_5"> <menu action="ZenCodingMenuAction"> <menuitem name="ZenCodingExpand" action="ZenCodingExpandAction"/> <menuitem name="ZenCodingExpandW" action="ZenCodingExpandWAction"/> <menuitem name="ZenCodingWrap" action="ZenCodingWrapAction"/> <separator/> <menuitem name="ZenCodingInward" action="ZenCodingInwardAction"/> <menuitem name="ZenCodingOutward" action="ZenCodingOutwardAction"/> <menuitem name="ZenCodingMerge" action="ZenCodingMergeAction"/> <separator/> <menuitem name="ZenCodingPrev" action="ZenCodingPrevAction"/> <menuitem name="ZenCodingNext" action="ZenCodingNextAction"/> <separator/> <menuitem name="ZenCodingRemove" action="ZenCodingRemoveAction"/> <menuitem name="ZenCodingSplit" action="ZenCodingSplitAction"/> <menuitem name="ZenCodingComment" action="ZenCodingCommentAction"/> </menu> </placeholder> </menu> </menubar> </ui> """ class ZenCodingPlugin(pluma.Plugin): """A Pluma plugin to implement Zen Coding's HTML and CSS shorthand expander.""" def activate(self, window): actions = [ ('ZenCodingMenuAction', None, '_Zen Coding', None, "Zen Coding tools", None), ('ZenCodingExpandAction', None, '_Expand abbreviation', '<Ctrl>E', "Expand abbreviation to raw HTML/CSS", self.expand_abbreviation), ('ZenCodingExpandWAction', None, 'E_xpand dynamic abbreviation...', '<Ctrl><Alt>E', "Dynamically expand abbreviation as you type", self.expand_with_abbreviation), ('ZenCodingWrapAction', None, '_Wrap with abbreviation...', '<Ctrl><Shift>E', "Wrap with code expanded from abbreviation", self.wrap_with_abbreviation), ('ZenCodingInwardAction', None, 'Balance tag _inward', '<Ctrl><Alt>I', "Select inner tag's content", self.match_pair_inward), ('ZenCodingOutwardAction', None, 'Balance tag _outward', '<Ctrl><Alt>O', "Select outer tag's content", self.match_pair_outward), ('ZenCodingMergeAction', None, '_Merge lines', '<Ctrl><Alt>M', "Merge all lines of the current selection", self.merge_lines), ('ZenCodingPrevAction', None, '_Previous edit point', '<Alt>Left', "Place the cursor at the previous edit point", self.prev_edit_point), ('ZenCodingNextAction', None, '_Next edit point', '<Alt>Right', "Place the cursor at the next edit point", self.next_edit_point), ('ZenCodingRemoveAction', None, '_Remove tag', '<Ctrl><Alt>R', "Remove a tag", self.remove_tag), ('ZenCodingSplitAction', None, 'Split or _join tag', '<Ctrl><Alt>J', "Toggle between single and double tag", self.split_join_tag), ('ZenCodingCommentAction', None, 'Toggle _comment', '<Ctrl><Alt>C', "Toggle an XML or HTML comment", self.toggle_comment) ] windowdata = dict() window.set_data("ZenCodingPluginDataKey", windowdata) windowdata["action_group"] = gtk.ActionGroup("PlumaZenCodingPluginActions") windowdata["action_group"].add_actions(actions, window) manager = window.get_ui_manager() manager.insert_action_group(windowdata["action_group"], -1) windowdata["ui_id"] = manager.add_ui_from_string(zencoding_ui_str) window.set_data("ZenCodingPluginInfo", windowdata) self.editor = ZenEditor() error = self.editor.get_user_settings_error() if error: md = gtk.MessageDialog(window, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE, "There is an error in user settings:") message = "{0} on line {1} at character {2}\n\nUser settings will not be available." md.set_title("Zen Coding error") md.format_secondary_text(message.format(error['msg'], error['lineno'], error['offset'])) md.run() md.destroy() def deactivate(self, window): <|fim_middle|> def update_ui(self, window): view = window.get_active_view() windowdata = window.get_data("ZenCodingPluginDataKey") windowdata["action_group"].set_sensitive(bool(view and view.get_editable())) def expand_abbreviation(self, action, window): self.editor.expand_abbreviation(window) def expand_with_abbreviation(self, action, window): self.editor.expand_with_abbreviation(window) def wrap_with_abbreviation(self, action, window): self.editor.wrap_with_abbreviation(window) def match_pair_inward(self, action, window): self.editor.match_pair_inward(window) def match_pair_outward(self, action, window): self.editor.match_pair_outward(window) def merge_lines(self, action, window): self.editor.merge_lines(window) def prev_edit_point(self, action, window): self.editor.prev_edit_point(window) def next_edit_point(self, action, window): self.editor.next_edit_point(window) def remove_tag(self, action, window): self.editor.remove_tag(window) def split_join_tag(self, action, window): self.editor.split_join_tag(window) def toggle_comment(self, action, window): self.editor.toggle_comment(window) <|fim▁end|>
windowdata = window.get_data("ZenCodingPluginDataKey") manager = window.get_ui_manager() manager.remove_ui(windowdata["ui_id"]) manager.remove_action_group(windowdata["action_group"])
<|file_name|>plugin.py<|end_file_name|><|fim▁begin|># @file plugin.py # # Connect Zen Coding to Pluma. # # Adapted to pluma by Joao Manoel ([email protected]) # # Original Author Franck Marcia ([email protected]) # import pluma, gobject, gtk, os from zen_editor import ZenEditor zencoding_ui_str = """ <ui> <menubar name="MenuBar"> <menu name="EditMenu" action="Edit"> <placeholder name="EditOps_5"> <menu action="ZenCodingMenuAction"> <menuitem name="ZenCodingExpand" action="ZenCodingExpandAction"/> <menuitem name="ZenCodingExpandW" action="ZenCodingExpandWAction"/> <menuitem name="ZenCodingWrap" action="ZenCodingWrapAction"/> <separator/> <menuitem name="ZenCodingInward" action="ZenCodingInwardAction"/> <menuitem name="ZenCodingOutward" action="ZenCodingOutwardAction"/> <menuitem name="ZenCodingMerge" action="ZenCodingMergeAction"/> <separator/> <menuitem name="ZenCodingPrev" action="ZenCodingPrevAction"/> <menuitem name="ZenCodingNext" action="ZenCodingNextAction"/> <separator/> <menuitem name="ZenCodingRemove" action="ZenCodingRemoveAction"/> <menuitem name="ZenCodingSplit" action="ZenCodingSplitAction"/> <menuitem name="ZenCodingComment" action="ZenCodingCommentAction"/> </menu> </placeholder> </menu> </menubar> </ui> """ class ZenCodingPlugin(pluma.Plugin): """A Pluma plugin to implement Zen Coding's HTML and CSS shorthand expander.""" def activate(self, window): actions = [ ('ZenCodingMenuAction', None, '_Zen Coding', None, "Zen Coding tools", None), ('ZenCodingExpandAction', None, '_Expand abbreviation', '<Ctrl>E', "Expand abbreviation to raw HTML/CSS", self.expand_abbreviation), ('ZenCodingExpandWAction', None, 'E_xpand dynamic abbreviation...', '<Ctrl><Alt>E', "Dynamically expand abbreviation as you type", self.expand_with_abbreviation), ('ZenCodingWrapAction', None, '_Wrap with abbreviation...', '<Ctrl><Shift>E', "Wrap with code expanded from abbreviation", self.wrap_with_abbreviation), ('ZenCodingInwardAction', None, 'Balance tag _inward', '<Ctrl><Alt>I', "Select inner tag's content", self.match_pair_inward), ('ZenCodingOutwardAction', None, 'Balance tag _outward', '<Ctrl><Alt>O', "Select outer tag's content", self.match_pair_outward), ('ZenCodingMergeAction', None, '_Merge lines', '<Ctrl><Alt>M', "Merge all lines of the current selection", self.merge_lines), ('ZenCodingPrevAction', None, '_Previous edit point', '<Alt>Left', "Place the cursor at the previous edit point", self.prev_edit_point), ('ZenCodingNextAction', None, '_Next edit point', '<Alt>Right', "Place the cursor at the next edit point", self.next_edit_point), ('ZenCodingRemoveAction', None, '_Remove tag', '<Ctrl><Alt>R', "Remove a tag", self.remove_tag), ('ZenCodingSplitAction', None, 'Split or _join tag', '<Ctrl><Alt>J', "Toggle between single and double tag", self.split_join_tag), ('ZenCodingCommentAction', None, 'Toggle _comment', '<Ctrl><Alt>C', "Toggle an XML or HTML comment", self.toggle_comment) ] windowdata = dict() window.set_data("ZenCodingPluginDataKey", windowdata) windowdata["action_group"] = gtk.ActionGroup("PlumaZenCodingPluginActions") windowdata["action_group"].add_actions(actions, window) manager = window.get_ui_manager() manager.insert_action_group(windowdata["action_group"], -1) windowdata["ui_id"] = manager.add_ui_from_string(zencoding_ui_str) window.set_data("ZenCodingPluginInfo", windowdata) self.editor = ZenEditor() error = self.editor.get_user_settings_error() if error: md = gtk.MessageDialog(window, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE, "There is an error in user settings:") message = "{0} on line {1} at character {2}\n\nUser settings will not be available." md.set_title("Zen Coding error") md.format_secondary_text(message.format(error['msg'], error['lineno'], error['offset'])) md.run() md.destroy() def deactivate(self, window): windowdata = window.get_data("ZenCodingPluginDataKey") manager = window.get_ui_manager() manager.remove_ui(windowdata["ui_id"]) manager.remove_action_group(windowdata["action_group"]) def update_ui(self, window): <|fim_middle|> def expand_abbreviation(self, action, window): self.editor.expand_abbreviation(window) def expand_with_abbreviation(self, action, window): self.editor.expand_with_abbreviation(window) def wrap_with_abbreviation(self, action, window): self.editor.wrap_with_abbreviation(window) def match_pair_inward(self, action, window): self.editor.match_pair_inward(window) def match_pair_outward(self, action, window): self.editor.match_pair_outward(window) def merge_lines(self, action, window): self.editor.merge_lines(window) def prev_edit_point(self, action, window): self.editor.prev_edit_point(window) def next_edit_point(self, action, window): self.editor.next_edit_point(window) def remove_tag(self, action, window): self.editor.remove_tag(window) def split_join_tag(self, action, window): self.editor.split_join_tag(window) def toggle_comment(self, action, window): self.editor.toggle_comment(window) <|fim▁end|>
view = window.get_active_view() windowdata = window.get_data("ZenCodingPluginDataKey") windowdata["action_group"].set_sensitive(bool(view and view.get_editable()))
<|file_name|>plugin.py<|end_file_name|><|fim▁begin|># @file plugin.py # # Connect Zen Coding to Pluma. # # Adapted to pluma by Joao Manoel ([email protected]) # # Original Author Franck Marcia ([email protected]) # import pluma, gobject, gtk, os from zen_editor import ZenEditor zencoding_ui_str = """ <ui> <menubar name="MenuBar"> <menu name="EditMenu" action="Edit"> <placeholder name="EditOps_5"> <menu action="ZenCodingMenuAction"> <menuitem name="ZenCodingExpand" action="ZenCodingExpandAction"/> <menuitem name="ZenCodingExpandW" action="ZenCodingExpandWAction"/> <menuitem name="ZenCodingWrap" action="ZenCodingWrapAction"/> <separator/> <menuitem name="ZenCodingInward" action="ZenCodingInwardAction"/> <menuitem name="ZenCodingOutward" action="ZenCodingOutwardAction"/> <menuitem name="ZenCodingMerge" action="ZenCodingMergeAction"/> <separator/> <menuitem name="ZenCodingPrev" action="ZenCodingPrevAction"/> <menuitem name="ZenCodingNext" action="ZenCodingNextAction"/> <separator/> <menuitem name="ZenCodingRemove" action="ZenCodingRemoveAction"/> <menuitem name="ZenCodingSplit" action="ZenCodingSplitAction"/> <menuitem name="ZenCodingComment" action="ZenCodingCommentAction"/> </menu> </placeholder> </menu> </menubar> </ui> """ class ZenCodingPlugin(pluma.Plugin): """A Pluma plugin to implement Zen Coding's HTML and CSS shorthand expander.""" def activate(self, window): actions = [ ('ZenCodingMenuAction', None, '_Zen Coding', None, "Zen Coding tools", None), ('ZenCodingExpandAction', None, '_Expand abbreviation', '<Ctrl>E', "Expand abbreviation to raw HTML/CSS", self.expand_abbreviation), ('ZenCodingExpandWAction', None, 'E_xpand dynamic abbreviation...', '<Ctrl><Alt>E', "Dynamically expand abbreviation as you type", self.expand_with_abbreviation), ('ZenCodingWrapAction', None, '_Wrap with abbreviation...', '<Ctrl><Shift>E', "Wrap with code expanded from abbreviation", self.wrap_with_abbreviation), ('ZenCodingInwardAction', None, 'Balance tag _inward', '<Ctrl><Alt>I', "Select inner tag's content", self.match_pair_inward), ('ZenCodingOutwardAction', None, 'Balance tag _outward', '<Ctrl><Alt>O', "Select outer tag's content", self.match_pair_outward), ('ZenCodingMergeAction', None, '_Merge lines', '<Ctrl><Alt>M', "Merge all lines of the current selection", self.merge_lines), ('ZenCodingPrevAction', None, '_Previous edit point', '<Alt>Left', "Place the cursor at the previous edit point", self.prev_edit_point), ('ZenCodingNextAction', None, '_Next edit point', '<Alt>Right', "Place the cursor at the next edit point", self.next_edit_point), ('ZenCodingRemoveAction', None, '_Remove tag', '<Ctrl><Alt>R', "Remove a tag", self.remove_tag), ('ZenCodingSplitAction', None, 'Split or _join tag', '<Ctrl><Alt>J', "Toggle between single and double tag", self.split_join_tag), ('ZenCodingCommentAction', None, 'Toggle _comment', '<Ctrl><Alt>C', "Toggle an XML or HTML comment", self.toggle_comment) ] windowdata = dict() window.set_data("ZenCodingPluginDataKey", windowdata) windowdata["action_group"] = gtk.ActionGroup("PlumaZenCodingPluginActions") windowdata["action_group"].add_actions(actions, window) manager = window.get_ui_manager() manager.insert_action_group(windowdata["action_group"], -1) windowdata["ui_id"] = manager.add_ui_from_string(zencoding_ui_str) window.set_data("ZenCodingPluginInfo", windowdata) self.editor = ZenEditor() error = self.editor.get_user_settings_error() if error: md = gtk.MessageDialog(window, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE, "There is an error in user settings:") message = "{0} on line {1} at character {2}\n\nUser settings will not be available." md.set_title("Zen Coding error") md.format_secondary_text(message.format(error['msg'], error['lineno'], error['offset'])) md.run() md.destroy() def deactivate(self, window): windowdata = window.get_data("ZenCodingPluginDataKey") manager = window.get_ui_manager() manager.remove_ui(windowdata["ui_id"]) manager.remove_action_group(windowdata["action_group"]) def update_ui(self, window): view = window.get_active_view() windowdata = window.get_data("ZenCodingPluginDataKey") windowdata["action_group"].set_sensitive(bool(view and view.get_editable())) def expand_abbreviation(self, action, window): <|fim_middle|> def expand_with_abbreviation(self, action, window): self.editor.expand_with_abbreviation(window) def wrap_with_abbreviation(self, action, window): self.editor.wrap_with_abbreviation(window) def match_pair_inward(self, action, window): self.editor.match_pair_inward(window) def match_pair_outward(self, action, window): self.editor.match_pair_outward(window) def merge_lines(self, action, window): self.editor.merge_lines(window) def prev_edit_point(self, action, window): self.editor.prev_edit_point(window) def next_edit_point(self, action, window): self.editor.next_edit_point(window) def remove_tag(self, action, window): self.editor.remove_tag(window) def split_join_tag(self, action, window): self.editor.split_join_tag(window) def toggle_comment(self, action, window): self.editor.toggle_comment(window) <|fim▁end|>
self.editor.expand_abbreviation(window)
<|file_name|>plugin.py<|end_file_name|><|fim▁begin|># @file plugin.py # # Connect Zen Coding to Pluma. # # Adapted to pluma by Joao Manoel ([email protected]) # # Original Author Franck Marcia ([email protected]) # import pluma, gobject, gtk, os from zen_editor import ZenEditor zencoding_ui_str = """ <ui> <menubar name="MenuBar"> <menu name="EditMenu" action="Edit"> <placeholder name="EditOps_5"> <menu action="ZenCodingMenuAction"> <menuitem name="ZenCodingExpand" action="ZenCodingExpandAction"/> <menuitem name="ZenCodingExpandW" action="ZenCodingExpandWAction"/> <menuitem name="ZenCodingWrap" action="ZenCodingWrapAction"/> <separator/> <menuitem name="ZenCodingInward" action="ZenCodingInwardAction"/> <menuitem name="ZenCodingOutward" action="ZenCodingOutwardAction"/> <menuitem name="ZenCodingMerge" action="ZenCodingMergeAction"/> <separator/> <menuitem name="ZenCodingPrev" action="ZenCodingPrevAction"/> <menuitem name="ZenCodingNext" action="ZenCodingNextAction"/> <separator/> <menuitem name="ZenCodingRemove" action="ZenCodingRemoveAction"/> <menuitem name="ZenCodingSplit" action="ZenCodingSplitAction"/> <menuitem name="ZenCodingComment" action="ZenCodingCommentAction"/> </menu> </placeholder> </menu> </menubar> </ui> """ class ZenCodingPlugin(pluma.Plugin): """A Pluma plugin to implement Zen Coding's HTML and CSS shorthand expander.""" def activate(self, window): actions = [ ('ZenCodingMenuAction', None, '_Zen Coding', None, "Zen Coding tools", None), ('ZenCodingExpandAction', None, '_Expand abbreviation', '<Ctrl>E', "Expand abbreviation to raw HTML/CSS", self.expand_abbreviation), ('ZenCodingExpandWAction', None, 'E_xpand dynamic abbreviation...', '<Ctrl><Alt>E', "Dynamically expand abbreviation as you type", self.expand_with_abbreviation), ('ZenCodingWrapAction', None, '_Wrap with abbreviation...', '<Ctrl><Shift>E', "Wrap with code expanded from abbreviation", self.wrap_with_abbreviation), ('ZenCodingInwardAction', None, 'Balance tag _inward', '<Ctrl><Alt>I', "Select inner tag's content", self.match_pair_inward), ('ZenCodingOutwardAction', None, 'Balance tag _outward', '<Ctrl><Alt>O', "Select outer tag's content", self.match_pair_outward), ('ZenCodingMergeAction', None, '_Merge lines', '<Ctrl><Alt>M', "Merge all lines of the current selection", self.merge_lines), ('ZenCodingPrevAction', None, '_Previous edit point', '<Alt>Left', "Place the cursor at the previous edit point", self.prev_edit_point), ('ZenCodingNextAction', None, '_Next edit point', '<Alt>Right', "Place the cursor at the next edit point", self.next_edit_point), ('ZenCodingRemoveAction', None, '_Remove tag', '<Ctrl><Alt>R', "Remove a tag", self.remove_tag), ('ZenCodingSplitAction', None, 'Split or _join tag', '<Ctrl><Alt>J', "Toggle between single and double tag", self.split_join_tag), ('ZenCodingCommentAction', None, 'Toggle _comment', '<Ctrl><Alt>C', "Toggle an XML or HTML comment", self.toggle_comment) ] windowdata = dict() window.set_data("ZenCodingPluginDataKey", windowdata) windowdata["action_group"] = gtk.ActionGroup("PlumaZenCodingPluginActions") windowdata["action_group"].add_actions(actions, window) manager = window.get_ui_manager() manager.insert_action_group(windowdata["action_group"], -1) windowdata["ui_id"] = manager.add_ui_from_string(zencoding_ui_str) window.set_data("ZenCodingPluginInfo", windowdata) self.editor = ZenEditor() error = self.editor.get_user_settings_error() if error: md = gtk.MessageDialog(window, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE, "There is an error in user settings:") message = "{0} on line {1} at character {2}\n\nUser settings will not be available." md.set_title("Zen Coding error") md.format_secondary_text(message.format(error['msg'], error['lineno'], error['offset'])) md.run() md.destroy() def deactivate(self, window): windowdata = window.get_data("ZenCodingPluginDataKey") manager = window.get_ui_manager() manager.remove_ui(windowdata["ui_id"]) manager.remove_action_group(windowdata["action_group"]) def update_ui(self, window): view = window.get_active_view() windowdata = window.get_data("ZenCodingPluginDataKey") windowdata["action_group"].set_sensitive(bool(view and view.get_editable())) def expand_abbreviation(self, action, window): self.editor.expand_abbreviation(window) def expand_with_abbreviation(self, action, window): <|fim_middle|> def wrap_with_abbreviation(self, action, window): self.editor.wrap_with_abbreviation(window) def match_pair_inward(self, action, window): self.editor.match_pair_inward(window) def match_pair_outward(self, action, window): self.editor.match_pair_outward(window) def merge_lines(self, action, window): self.editor.merge_lines(window) def prev_edit_point(self, action, window): self.editor.prev_edit_point(window) def next_edit_point(self, action, window): self.editor.next_edit_point(window) def remove_tag(self, action, window): self.editor.remove_tag(window) def split_join_tag(self, action, window): self.editor.split_join_tag(window) def toggle_comment(self, action, window): self.editor.toggle_comment(window) <|fim▁end|>
self.editor.expand_with_abbreviation(window)
<|file_name|>plugin.py<|end_file_name|><|fim▁begin|># @file plugin.py # # Connect Zen Coding to Pluma. # # Adapted to pluma by Joao Manoel ([email protected]) # # Original Author Franck Marcia ([email protected]) # import pluma, gobject, gtk, os from zen_editor import ZenEditor zencoding_ui_str = """ <ui> <menubar name="MenuBar"> <menu name="EditMenu" action="Edit"> <placeholder name="EditOps_5"> <menu action="ZenCodingMenuAction"> <menuitem name="ZenCodingExpand" action="ZenCodingExpandAction"/> <menuitem name="ZenCodingExpandW" action="ZenCodingExpandWAction"/> <menuitem name="ZenCodingWrap" action="ZenCodingWrapAction"/> <separator/> <menuitem name="ZenCodingInward" action="ZenCodingInwardAction"/> <menuitem name="ZenCodingOutward" action="ZenCodingOutwardAction"/> <menuitem name="ZenCodingMerge" action="ZenCodingMergeAction"/> <separator/> <menuitem name="ZenCodingPrev" action="ZenCodingPrevAction"/> <menuitem name="ZenCodingNext" action="ZenCodingNextAction"/> <separator/> <menuitem name="ZenCodingRemove" action="ZenCodingRemoveAction"/> <menuitem name="ZenCodingSplit" action="ZenCodingSplitAction"/> <menuitem name="ZenCodingComment" action="ZenCodingCommentAction"/> </menu> </placeholder> </menu> </menubar> </ui> """ class ZenCodingPlugin(pluma.Plugin): """A Pluma plugin to implement Zen Coding's HTML and CSS shorthand expander.""" def activate(self, window): actions = [ ('ZenCodingMenuAction', None, '_Zen Coding', None, "Zen Coding tools", None), ('ZenCodingExpandAction', None, '_Expand abbreviation', '<Ctrl>E', "Expand abbreviation to raw HTML/CSS", self.expand_abbreviation), ('ZenCodingExpandWAction', None, 'E_xpand dynamic abbreviation...', '<Ctrl><Alt>E', "Dynamically expand abbreviation as you type", self.expand_with_abbreviation), ('ZenCodingWrapAction', None, '_Wrap with abbreviation...', '<Ctrl><Shift>E', "Wrap with code expanded from abbreviation", self.wrap_with_abbreviation), ('ZenCodingInwardAction', None, 'Balance tag _inward', '<Ctrl><Alt>I', "Select inner tag's content", self.match_pair_inward), ('ZenCodingOutwardAction', None, 'Balance tag _outward', '<Ctrl><Alt>O', "Select outer tag's content", self.match_pair_outward), ('ZenCodingMergeAction', None, '_Merge lines', '<Ctrl><Alt>M', "Merge all lines of the current selection", self.merge_lines), ('ZenCodingPrevAction', None, '_Previous edit point', '<Alt>Left', "Place the cursor at the previous edit point", self.prev_edit_point), ('ZenCodingNextAction', None, '_Next edit point', '<Alt>Right', "Place the cursor at the next edit point", self.next_edit_point), ('ZenCodingRemoveAction', None, '_Remove tag', '<Ctrl><Alt>R', "Remove a tag", self.remove_tag), ('ZenCodingSplitAction', None, 'Split or _join tag', '<Ctrl><Alt>J', "Toggle between single and double tag", self.split_join_tag), ('ZenCodingCommentAction', None, 'Toggle _comment', '<Ctrl><Alt>C', "Toggle an XML or HTML comment", self.toggle_comment) ] windowdata = dict() window.set_data("ZenCodingPluginDataKey", windowdata) windowdata["action_group"] = gtk.ActionGroup("PlumaZenCodingPluginActions") windowdata["action_group"].add_actions(actions, window) manager = window.get_ui_manager() manager.insert_action_group(windowdata["action_group"], -1) windowdata["ui_id"] = manager.add_ui_from_string(zencoding_ui_str) window.set_data("ZenCodingPluginInfo", windowdata) self.editor = ZenEditor() error = self.editor.get_user_settings_error() if error: md = gtk.MessageDialog(window, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE, "There is an error in user settings:") message = "{0} on line {1} at character {2}\n\nUser settings will not be available." md.set_title("Zen Coding error") md.format_secondary_text(message.format(error['msg'], error['lineno'], error['offset'])) md.run() md.destroy() def deactivate(self, window): windowdata = window.get_data("ZenCodingPluginDataKey") manager = window.get_ui_manager() manager.remove_ui(windowdata["ui_id"]) manager.remove_action_group(windowdata["action_group"]) def update_ui(self, window): view = window.get_active_view() windowdata = window.get_data("ZenCodingPluginDataKey") windowdata["action_group"].set_sensitive(bool(view and view.get_editable())) def expand_abbreviation(self, action, window): self.editor.expand_abbreviation(window) def expand_with_abbreviation(self, action, window): self.editor.expand_with_abbreviation(window) def wrap_with_abbreviation(self, action, window): <|fim_middle|> def match_pair_inward(self, action, window): self.editor.match_pair_inward(window) def match_pair_outward(self, action, window): self.editor.match_pair_outward(window) def merge_lines(self, action, window): self.editor.merge_lines(window) def prev_edit_point(self, action, window): self.editor.prev_edit_point(window) def next_edit_point(self, action, window): self.editor.next_edit_point(window) def remove_tag(self, action, window): self.editor.remove_tag(window) def split_join_tag(self, action, window): self.editor.split_join_tag(window) def toggle_comment(self, action, window): self.editor.toggle_comment(window) <|fim▁end|>
self.editor.wrap_with_abbreviation(window)
<|file_name|>plugin.py<|end_file_name|><|fim▁begin|># @file plugin.py # # Connect Zen Coding to Pluma. # # Adapted to pluma by Joao Manoel ([email protected]) # # Original Author Franck Marcia ([email protected]) # import pluma, gobject, gtk, os from zen_editor import ZenEditor zencoding_ui_str = """ <ui> <menubar name="MenuBar"> <menu name="EditMenu" action="Edit"> <placeholder name="EditOps_5"> <menu action="ZenCodingMenuAction"> <menuitem name="ZenCodingExpand" action="ZenCodingExpandAction"/> <menuitem name="ZenCodingExpandW" action="ZenCodingExpandWAction"/> <menuitem name="ZenCodingWrap" action="ZenCodingWrapAction"/> <separator/> <menuitem name="ZenCodingInward" action="ZenCodingInwardAction"/> <menuitem name="ZenCodingOutward" action="ZenCodingOutwardAction"/> <menuitem name="ZenCodingMerge" action="ZenCodingMergeAction"/> <separator/> <menuitem name="ZenCodingPrev" action="ZenCodingPrevAction"/> <menuitem name="ZenCodingNext" action="ZenCodingNextAction"/> <separator/> <menuitem name="ZenCodingRemove" action="ZenCodingRemoveAction"/> <menuitem name="ZenCodingSplit" action="ZenCodingSplitAction"/> <menuitem name="ZenCodingComment" action="ZenCodingCommentAction"/> </menu> </placeholder> </menu> </menubar> </ui> """ class ZenCodingPlugin(pluma.Plugin): """A Pluma plugin to implement Zen Coding's HTML and CSS shorthand expander.""" def activate(self, window): actions = [ ('ZenCodingMenuAction', None, '_Zen Coding', None, "Zen Coding tools", None), ('ZenCodingExpandAction', None, '_Expand abbreviation', '<Ctrl>E', "Expand abbreviation to raw HTML/CSS", self.expand_abbreviation), ('ZenCodingExpandWAction', None, 'E_xpand dynamic abbreviation...', '<Ctrl><Alt>E', "Dynamically expand abbreviation as you type", self.expand_with_abbreviation), ('ZenCodingWrapAction', None, '_Wrap with abbreviation...', '<Ctrl><Shift>E', "Wrap with code expanded from abbreviation", self.wrap_with_abbreviation), ('ZenCodingInwardAction', None, 'Balance tag _inward', '<Ctrl><Alt>I', "Select inner tag's content", self.match_pair_inward), ('ZenCodingOutwardAction', None, 'Balance tag _outward', '<Ctrl><Alt>O', "Select outer tag's content", self.match_pair_outward), ('ZenCodingMergeAction', None, '_Merge lines', '<Ctrl><Alt>M', "Merge all lines of the current selection", self.merge_lines), ('ZenCodingPrevAction', None, '_Previous edit point', '<Alt>Left', "Place the cursor at the previous edit point", self.prev_edit_point), ('ZenCodingNextAction', None, '_Next edit point', '<Alt>Right', "Place the cursor at the next edit point", self.next_edit_point), ('ZenCodingRemoveAction', None, '_Remove tag', '<Ctrl><Alt>R', "Remove a tag", self.remove_tag), ('ZenCodingSplitAction', None, 'Split or _join tag', '<Ctrl><Alt>J', "Toggle between single and double tag", self.split_join_tag), ('ZenCodingCommentAction', None, 'Toggle _comment', '<Ctrl><Alt>C', "Toggle an XML or HTML comment", self.toggle_comment) ] windowdata = dict() window.set_data("ZenCodingPluginDataKey", windowdata) windowdata["action_group"] = gtk.ActionGroup("PlumaZenCodingPluginActions") windowdata["action_group"].add_actions(actions, window) manager = window.get_ui_manager() manager.insert_action_group(windowdata["action_group"], -1) windowdata["ui_id"] = manager.add_ui_from_string(zencoding_ui_str) window.set_data("ZenCodingPluginInfo", windowdata) self.editor = ZenEditor() error = self.editor.get_user_settings_error() if error: md = gtk.MessageDialog(window, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE, "There is an error in user settings:") message = "{0} on line {1} at character {2}\n\nUser settings will not be available." md.set_title("Zen Coding error") md.format_secondary_text(message.format(error['msg'], error['lineno'], error['offset'])) md.run() md.destroy() def deactivate(self, window): windowdata = window.get_data("ZenCodingPluginDataKey") manager = window.get_ui_manager() manager.remove_ui(windowdata["ui_id"]) manager.remove_action_group(windowdata["action_group"]) def update_ui(self, window): view = window.get_active_view() windowdata = window.get_data("ZenCodingPluginDataKey") windowdata["action_group"].set_sensitive(bool(view and view.get_editable())) def expand_abbreviation(self, action, window): self.editor.expand_abbreviation(window) def expand_with_abbreviation(self, action, window): self.editor.expand_with_abbreviation(window) def wrap_with_abbreviation(self, action, window): self.editor.wrap_with_abbreviation(window) def match_pair_inward(self, action, window): <|fim_middle|> def match_pair_outward(self, action, window): self.editor.match_pair_outward(window) def merge_lines(self, action, window): self.editor.merge_lines(window) def prev_edit_point(self, action, window): self.editor.prev_edit_point(window) def next_edit_point(self, action, window): self.editor.next_edit_point(window) def remove_tag(self, action, window): self.editor.remove_tag(window) def split_join_tag(self, action, window): self.editor.split_join_tag(window) def toggle_comment(self, action, window): self.editor.toggle_comment(window) <|fim▁end|>
self.editor.match_pair_inward(window)
<|file_name|>plugin.py<|end_file_name|><|fim▁begin|># @file plugin.py # # Connect Zen Coding to Pluma. # # Adapted to pluma by Joao Manoel ([email protected]) # # Original Author Franck Marcia ([email protected]) # import pluma, gobject, gtk, os from zen_editor import ZenEditor zencoding_ui_str = """ <ui> <menubar name="MenuBar"> <menu name="EditMenu" action="Edit"> <placeholder name="EditOps_5"> <menu action="ZenCodingMenuAction"> <menuitem name="ZenCodingExpand" action="ZenCodingExpandAction"/> <menuitem name="ZenCodingExpandW" action="ZenCodingExpandWAction"/> <menuitem name="ZenCodingWrap" action="ZenCodingWrapAction"/> <separator/> <menuitem name="ZenCodingInward" action="ZenCodingInwardAction"/> <menuitem name="ZenCodingOutward" action="ZenCodingOutwardAction"/> <menuitem name="ZenCodingMerge" action="ZenCodingMergeAction"/> <separator/> <menuitem name="ZenCodingPrev" action="ZenCodingPrevAction"/> <menuitem name="ZenCodingNext" action="ZenCodingNextAction"/> <separator/> <menuitem name="ZenCodingRemove" action="ZenCodingRemoveAction"/> <menuitem name="ZenCodingSplit" action="ZenCodingSplitAction"/> <menuitem name="ZenCodingComment" action="ZenCodingCommentAction"/> </menu> </placeholder> </menu> </menubar> </ui> """ class ZenCodingPlugin(pluma.Plugin): """A Pluma plugin to implement Zen Coding's HTML and CSS shorthand expander.""" def activate(self, window): actions = [ ('ZenCodingMenuAction', None, '_Zen Coding', None, "Zen Coding tools", None), ('ZenCodingExpandAction', None, '_Expand abbreviation', '<Ctrl>E', "Expand abbreviation to raw HTML/CSS", self.expand_abbreviation), ('ZenCodingExpandWAction', None, 'E_xpand dynamic abbreviation...', '<Ctrl><Alt>E', "Dynamically expand abbreviation as you type", self.expand_with_abbreviation), ('ZenCodingWrapAction', None, '_Wrap with abbreviation...', '<Ctrl><Shift>E', "Wrap with code expanded from abbreviation", self.wrap_with_abbreviation), ('ZenCodingInwardAction', None, 'Balance tag _inward', '<Ctrl><Alt>I', "Select inner tag's content", self.match_pair_inward), ('ZenCodingOutwardAction', None, 'Balance tag _outward', '<Ctrl><Alt>O', "Select outer tag's content", self.match_pair_outward), ('ZenCodingMergeAction', None, '_Merge lines', '<Ctrl><Alt>M', "Merge all lines of the current selection", self.merge_lines), ('ZenCodingPrevAction', None, '_Previous edit point', '<Alt>Left', "Place the cursor at the previous edit point", self.prev_edit_point), ('ZenCodingNextAction', None, '_Next edit point', '<Alt>Right', "Place the cursor at the next edit point", self.next_edit_point), ('ZenCodingRemoveAction', None, '_Remove tag', '<Ctrl><Alt>R', "Remove a tag", self.remove_tag), ('ZenCodingSplitAction', None, 'Split or _join tag', '<Ctrl><Alt>J', "Toggle between single and double tag", self.split_join_tag), ('ZenCodingCommentAction', None, 'Toggle _comment', '<Ctrl><Alt>C', "Toggle an XML or HTML comment", self.toggle_comment) ] windowdata = dict() window.set_data("ZenCodingPluginDataKey", windowdata) windowdata["action_group"] = gtk.ActionGroup("PlumaZenCodingPluginActions") windowdata["action_group"].add_actions(actions, window) manager = window.get_ui_manager() manager.insert_action_group(windowdata["action_group"], -1) windowdata["ui_id"] = manager.add_ui_from_string(zencoding_ui_str) window.set_data("ZenCodingPluginInfo", windowdata) self.editor = ZenEditor() error = self.editor.get_user_settings_error() if error: md = gtk.MessageDialog(window, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE, "There is an error in user settings:") message = "{0} on line {1} at character {2}\n\nUser settings will not be available." md.set_title("Zen Coding error") md.format_secondary_text(message.format(error['msg'], error['lineno'], error['offset'])) md.run() md.destroy() def deactivate(self, window): windowdata = window.get_data("ZenCodingPluginDataKey") manager = window.get_ui_manager() manager.remove_ui(windowdata["ui_id"]) manager.remove_action_group(windowdata["action_group"]) def update_ui(self, window): view = window.get_active_view() windowdata = window.get_data("ZenCodingPluginDataKey") windowdata["action_group"].set_sensitive(bool(view and view.get_editable())) def expand_abbreviation(self, action, window): self.editor.expand_abbreviation(window) def expand_with_abbreviation(self, action, window): self.editor.expand_with_abbreviation(window) def wrap_with_abbreviation(self, action, window): self.editor.wrap_with_abbreviation(window) def match_pair_inward(self, action, window): self.editor.match_pair_inward(window) def match_pair_outward(self, action, window): <|fim_middle|> def merge_lines(self, action, window): self.editor.merge_lines(window) def prev_edit_point(self, action, window): self.editor.prev_edit_point(window) def next_edit_point(self, action, window): self.editor.next_edit_point(window) def remove_tag(self, action, window): self.editor.remove_tag(window) def split_join_tag(self, action, window): self.editor.split_join_tag(window) def toggle_comment(self, action, window): self.editor.toggle_comment(window) <|fim▁end|>
self.editor.match_pair_outward(window)
<|file_name|>plugin.py<|end_file_name|><|fim▁begin|># @file plugin.py # # Connect Zen Coding to Pluma. # # Adapted to pluma by Joao Manoel ([email protected]) # # Original Author Franck Marcia ([email protected]) # import pluma, gobject, gtk, os from zen_editor import ZenEditor zencoding_ui_str = """ <ui> <menubar name="MenuBar"> <menu name="EditMenu" action="Edit"> <placeholder name="EditOps_5"> <menu action="ZenCodingMenuAction"> <menuitem name="ZenCodingExpand" action="ZenCodingExpandAction"/> <menuitem name="ZenCodingExpandW" action="ZenCodingExpandWAction"/> <menuitem name="ZenCodingWrap" action="ZenCodingWrapAction"/> <separator/> <menuitem name="ZenCodingInward" action="ZenCodingInwardAction"/> <menuitem name="ZenCodingOutward" action="ZenCodingOutwardAction"/> <menuitem name="ZenCodingMerge" action="ZenCodingMergeAction"/> <separator/> <menuitem name="ZenCodingPrev" action="ZenCodingPrevAction"/> <menuitem name="ZenCodingNext" action="ZenCodingNextAction"/> <separator/> <menuitem name="ZenCodingRemove" action="ZenCodingRemoveAction"/> <menuitem name="ZenCodingSplit" action="ZenCodingSplitAction"/> <menuitem name="ZenCodingComment" action="ZenCodingCommentAction"/> </menu> </placeholder> </menu> </menubar> </ui> """ class ZenCodingPlugin(pluma.Plugin): """A Pluma plugin to implement Zen Coding's HTML and CSS shorthand expander.""" def activate(self, window): actions = [ ('ZenCodingMenuAction', None, '_Zen Coding', None, "Zen Coding tools", None), ('ZenCodingExpandAction', None, '_Expand abbreviation', '<Ctrl>E', "Expand abbreviation to raw HTML/CSS", self.expand_abbreviation), ('ZenCodingExpandWAction', None, 'E_xpand dynamic abbreviation...', '<Ctrl><Alt>E', "Dynamically expand abbreviation as you type", self.expand_with_abbreviation), ('ZenCodingWrapAction', None, '_Wrap with abbreviation...', '<Ctrl><Shift>E', "Wrap with code expanded from abbreviation", self.wrap_with_abbreviation), ('ZenCodingInwardAction', None, 'Balance tag _inward', '<Ctrl><Alt>I', "Select inner tag's content", self.match_pair_inward), ('ZenCodingOutwardAction', None, 'Balance tag _outward', '<Ctrl><Alt>O', "Select outer tag's content", self.match_pair_outward), ('ZenCodingMergeAction', None, '_Merge lines', '<Ctrl><Alt>M', "Merge all lines of the current selection", self.merge_lines), ('ZenCodingPrevAction', None, '_Previous edit point', '<Alt>Left', "Place the cursor at the previous edit point", self.prev_edit_point), ('ZenCodingNextAction', None, '_Next edit point', '<Alt>Right', "Place the cursor at the next edit point", self.next_edit_point), ('ZenCodingRemoveAction', None, '_Remove tag', '<Ctrl><Alt>R', "Remove a tag", self.remove_tag), ('ZenCodingSplitAction', None, 'Split or _join tag', '<Ctrl><Alt>J', "Toggle between single and double tag", self.split_join_tag), ('ZenCodingCommentAction', None, 'Toggle _comment', '<Ctrl><Alt>C', "Toggle an XML or HTML comment", self.toggle_comment) ] windowdata = dict() window.set_data("ZenCodingPluginDataKey", windowdata) windowdata["action_group"] = gtk.ActionGroup("PlumaZenCodingPluginActions") windowdata["action_group"].add_actions(actions, window) manager = window.get_ui_manager() manager.insert_action_group(windowdata["action_group"], -1) windowdata["ui_id"] = manager.add_ui_from_string(zencoding_ui_str) window.set_data("ZenCodingPluginInfo", windowdata) self.editor = ZenEditor() error = self.editor.get_user_settings_error() if error: md = gtk.MessageDialog(window, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE, "There is an error in user settings:") message = "{0} on line {1} at character {2}\n\nUser settings will not be available." md.set_title("Zen Coding error") md.format_secondary_text(message.format(error['msg'], error['lineno'], error['offset'])) md.run() md.destroy() def deactivate(self, window): windowdata = window.get_data("ZenCodingPluginDataKey") manager = window.get_ui_manager() manager.remove_ui(windowdata["ui_id"]) manager.remove_action_group(windowdata["action_group"]) def update_ui(self, window): view = window.get_active_view() windowdata = window.get_data("ZenCodingPluginDataKey") windowdata["action_group"].set_sensitive(bool(view and view.get_editable())) def expand_abbreviation(self, action, window): self.editor.expand_abbreviation(window) def expand_with_abbreviation(self, action, window): self.editor.expand_with_abbreviation(window) def wrap_with_abbreviation(self, action, window): self.editor.wrap_with_abbreviation(window) def match_pair_inward(self, action, window): self.editor.match_pair_inward(window) def match_pair_outward(self, action, window): self.editor.match_pair_outward(window) def merge_lines(self, action, window): <|fim_middle|> def prev_edit_point(self, action, window): self.editor.prev_edit_point(window) def next_edit_point(self, action, window): self.editor.next_edit_point(window) def remove_tag(self, action, window): self.editor.remove_tag(window) def split_join_tag(self, action, window): self.editor.split_join_tag(window) def toggle_comment(self, action, window): self.editor.toggle_comment(window) <|fim▁end|>
self.editor.merge_lines(window)
<|file_name|>plugin.py<|end_file_name|><|fim▁begin|># @file plugin.py # # Connect Zen Coding to Pluma. # # Adapted to pluma by Joao Manoel ([email protected]) # # Original Author Franck Marcia ([email protected]) # import pluma, gobject, gtk, os from zen_editor import ZenEditor zencoding_ui_str = """ <ui> <menubar name="MenuBar"> <menu name="EditMenu" action="Edit"> <placeholder name="EditOps_5"> <menu action="ZenCodingMenuAction"> <menuitem name="ZenCodingExpand" action="ZenCodingExpandAction"/> <menuitem name="ZenCodingExpandW" action="ZenCodingExpandWAction"/> <menuitem name="ZenCodingWrap" action="ZenCodingWrapAction"/> <separator/> <menuitem name="ZenCodingInward" action="ZenCodingInwardAction"/> <menuitem name="ZenCodingOutward" action="ZenCodingOutwardAction"/> <menuitem name="ZenCodingMerge" action="ZenCodingMergeAction"/> <separator/> <menuitem name="ZenCodingPrev" action="ZenCodingPrevAction"/> <menuitem name="ZenCodingNext" action="ZenCodingNextAction"/> <separator/> <menuitem name="ZenCodingRemove" action="ZenCodingRemoveAction"/> <menuitem name="ZenCodingSplit" action="ZenCodingSplitAction"/> <menuitem name="ZenCodingComment" action="ZenCodingCommentAction"/> </menu> </placeholder> </menu> </menubar> </ui> """ class ZenCodingPlugin(pluma.Plugin): """A Pluma plugin to implement Zen Coding's HTML and CSS shorthand expander.""" def activate(self, window): actions = [ ('ZenCodingMenuAction', None, '_Zen Coding', None, "Zen Coding tools", None), ('ZenCodingExpandAction', None, '_Expand abbreviation', '<Ctrl>E', "Expand abbreviation to raw HTML/CSS", self.expand_abbreviation), ('ZenCodingExpandWAction', None, 'E_xpand dynamic abbreviation...', '<Ctrl><Alt>E', "Dynamically expand abbreviation as you type", self.expand_with_abbreviation), ('ZenCodingWrapAction', None, '_Wrap with abbreviation...', '<Ctrl><Shift>E', "Wrap with code expanded from abbreviation", self.wrap_with_abbreviation), ('ZenCodingInwardAction', None, 'Balance tag _inward', '<Ctrl><Alt>I', "Select inner tag's content", self.match_pair_inward), ('ZenCodingOutwardAction', None, 'Balance tag _outward', '<Ctrl><Alt>O', "Select outer tag's content", self.match_pair_outward), ('ZenCodingMergeAction', None, '_Merge lines', '<Ctrl><Alt>M', "Merge all lines of the current selection", self.merge_lines), ('ZenCodingPrevAction', None, '_Previous edit point', '<Alt>Left', "Place the cursor at the previous edit point", self.prev_edit_point), ('ZenCodingNextAction', None, '_Next edit point', '<Alt>Right', "Place the cursor at the next edit point", self.next_edit_point), ('ZenCodingRemoveAction', None, '_Remove tag', '<Ctrl><Alt>R', "Remove a tag", self.remove_tag), ('ZenCodingSplitAction', None, 'Split or _join tag', '<Ctrl><Alt>J', "Toggle between single and double tag", self.split_join_tag), ('ZenCodingCommentAction', None, 'Toggle _comment', '<Ctrl><Alt>C', "Toggle an XML or HTML comment", self.toggle_comment) ] windowdata = dict() window.set_data("ZenCodingPluginDataKey", windowdata) windowdata["action_group"] = gtk.ActionGroup("PlumaZenCodingPluginActions") windowdata["action_group"].add_actions(actions, window) manager = window.get_ui_manager() manager.insert_action_group(windowdata["action_group"], -1) windowdata["ui_id"] = manager.add_ui_from_string(zencoding_ui_str) window.set_data("ZenCodingPluginInfo", windowdata) self.editor = ZenEditor() error = self.editor.get_user_settings_error() if error: md = gtk.MessageDialog(window, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE, "There is an error in user settings:") message = "{0} on line {1} at character {2}\n\nUser settings will not be available." md.set_title("Zen Coding error") md.format_secondary_text(message.format(error['msg'], error['lineno'], error['offset'])) md.run() md.destroy() def deactivate(self, window): windowdata = window.get_data("ZenCodingPluginDataKey") manager = window.get_ui_manager() manager.remove_ui(windowdata["ui_id"]) manager.remove_action_group(windowdata["action_group"]) def update_ui(self, window): view = window.get_active_view() windowdata = window.get_data("ZenCodingPluginDataKey") windowdata["action_group"].set_sensitive(bool(view and view.get_editable())) def expand_abbreviation(self, action, window): self.editor.expand_abbreviation(window) def expand_with_abbreviation(self, action, window): self.editor.expand_with_abbreviation(window) def wrap_with_abbreviation(self, action, window): self.editor.wrap_with_abbreviation(window) def match_pair_inward(self, action, window): self.editor.match_pair_inward(window) def match_pair_outward(self, action, window): self.editor.match_pair_outward(window) def merge_lines(self, action, window): self.editor.merge_lines(window) def prev_edit_point(self, action, window): <|fim_middle|> def next_edit_point(self, action, window): self.editor.next_edit_point(window) def remove_tag(self, action, window): self.editor.remove_tag(window) def split_join_tag(self, action, window): self.editor.split_join_tag(window) def toggle_comment(self, action, window): self.editor.toggle_comment(window) <|fim▁end|>
self.editor.prev_edit_point(window)
<|file_name|>plugin.py<|end_file_name|><|fim▁begin|># @file plugin.py # # Connect Zen Coding to Pluma. # # Adapted to pluma by Joao Manoel ([email protected]) # # Original Author Franck Marcia ([email protected]) # import pluma, gobject, gtk, os from zen_editor import ZenEditor zencoding_ui_str = """ <ui> <menubar name="MenuBar"> <menu name="EditMenu" action="Edit"> <placeholder name="EditOps_5"> <menu action="ZenCodingMenuAction"> <menuitem name="ZenCodingExpand" action="ZenCodingExpandAction"/> <menuitem name="ZenCodingExpandW" action="ZenCodingExpandWAction"/> <menuitem name="ZenCodingWrap" action="ZenCodingWrapAction"/> <separator/> <menuitem name="ZenCodingInward" action="ZenCodingInwardAction"/> <menuitem name="ZenCodingOutward" action="ZenCodingOutwardAction"/> <menuitem name="ZenCodingMerge" action="ZenCodingMergeAction"/> <separator/> <menuitem name="ZenCodingPrev" action="ZenCodingPrevAction"/> <menuitem name="ZenCodingNext" action="ZenCodingNextAction"/> <separator/> <menuitem name="ZenCodingRemove" action="ZenCodingRemoveAction"/> <menuitem name="ZenCodingSplit" action="ZenCodingSplitAction"/> <menuitem name="ZenCodingComment" action="ZenCodingCommentAction"/> </menu> </placeholder> </menu> </menubar> </ui> """ class ZenCodingPlugin(pluma.Plugin): """A Pluma plugin to implement Zen Coding's HTML and CSS shorthand expander.""" def activate(self, window): actions = [ ('ZenCodingMenuAction', None, '_Zen Coding', None, "Zen Coding tools", None), ('ZenCodingExpandAction', None, '_Expand abbreviation', '<Ctrl>E', "Expand abbreviation to raw HTML/CSS", self.expand_abbreviation), ('ZenCodingExpandWAction', None, 'E_xpand dynamic abbreviation...', '<Ctrl><Alt>E', "Dynamically expand abbreviation as you type", self.expand_with_abbreviation), ('ZenCodingWrapAction', None, '_Wrap with abbreviation...', '<Ctrl><Shift>E', "Wrap with code expanded from abbreviation", self.wrap_with_abbreviation), ('ZenCodingInwardAction', None, 'Balance tag _inward', '<Ctrl><Alt>I', "Select inner tag's content", self.match_pair_inward), ('ZenCodingOutwardAction', None, 'Balance tag _outward', '<Ctrl><Alt>O', "Select outer tag's content", self.match_pair_outward), ('ZenCodingMergeAction', None, '_Merge lines', '<Ctrl><Alt>M', "Merge all lines of the current selection", self.merge_lines), ('ZenCodingPrevAction', None, '_Previous edit point', '<Alt>Left', "Place the cursor at the previous edit point", self.prev_edit_point), ('ZenCodingNextAction', None, '_Next edit point', '<Alt>Right', "Place the cursor at the next edit point", self.next_edit_point), ('ZenCodingRemoveAction', None, '_Remove tag', '<Ctrl><Alt>R', "Remove a tag", self.remove_tag), ('ZenCodingSplitAction', None, 'Split or _join tag', '<Ctrl><Alt>J', "Toggle between single and double tag", self.split_join_tag), ('ZenCodingCommentAction', None, 'Toggle _comment', '<Ctrl><Alt>C', "Toggle an XML or HTML comment", self.toggle_comment) ] windowdata = dict() window.set_data("ZenCodingPluginDataKey", windowdata) windowdata["action_group"] = gtk.ActionGroup("PlumaZenCodingPluginActions") windowdata["action_group"].add_actions(actions, window) manager = window.get_ui_manager() manager.insert_action_group(windowdata["action_group"], -1) windowdata["ui_id"] = manager.add_ui_from_string(zencoding_ui_str) window.set_data("ZenCodingPluginInfo", windowdata) self.editor = ZenEditor() error = self.editor.get_user_settings_error() if error: md = gtk.MessageDialog(window, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE, "There is an error in user settings:") message = "{0} on line {1} at character {2}\n\nUser settings will not be available." md.set_title("Zen Coding error") md.format_secondary_text(message.format(error['msg'], error['lineno'], error['offset'])) md.run() md.destroy() def deactivate(self, window): windowdata = window.get_data("ZenCodingPluginDataKey") manager = window.get_ui_manager() manager.remove_ui(windowdata["ui_id"]) manager.remove_action_group(windowdata["action_group"]) def update_ui(self, window): view = window.get_active_view() windowdata = window.get_data("ZenCodingPluginDataKey") windowdata["action_group"].set_sensitive(bool(view and view.get_editable())) def expand_abbreviation(self, action, window): self.editor.expand_abbreviation(window) def expand_with_abbreviation(self, action, window): self.editor.expand_with_abbreviation(window) def wrap_with_abbreviation(self, action, window): self.editor.wrap_with_abbreviation(window) def match_pair_inward(self, action, window): self.editor.match_pair_inward(window) def match_pair_outward(self, action, window): self.editor.match_pair_outward(window) def merge_lines(self, action, window): self.editor.merge_lines(window) def prev_edit_point(self, action, window): self.editor.prev_edit_point(window) def next_edit_point(self, action, window): <|fim_middle|> def remove_tag(self, action, window): self.editor.remove_tag(window) def split_join_tag(self, action, window): self.editor.split_join_tag(window) def toggle_comment(self, action, window): self.editor.toggle_comment(window) <|fim▁end|>
self.editor.next_edit_point(window)
<|file_name|>plugin.py<|end_file_name|><|fim▁begin|># @file plugin.py # # Connect Zen Coding to Pluma. # # Adapted to pluma by Joao Manoel ([email protected]) # # Original Author Franck Marcia ([email protected]) # import pluma, gobject, gtk, os from zen_editor import ZenEditor zencoding_ui_str = """ <ui> <menubar name="MenuBar"> <menu name="EditMenu" action="Edit"> <placeholder name="EditOps_5"> <menu action="ZenCodingMenuAction"> <menuitem name="ZenCodingExpand" action="ZenCodingExpandAction"/> <menuitem name="ZenCodingExpandW" action="ZenCodingExpandWAction"/> <menuitem name="ZenCodingWrap" action="ZenCodingWrapAction"/> <separator/> <menuitem name="ZenCodingInward" action="ZenCodingInwardAction"/> <menuitem name="ZenCodingOutward" action="ZenCodingOutwardAction"/> <menuitem name="ZenCodingMerge" action="ZenCodingMergeAction"/> <separator/> <menuitem name="ZenCodingPrev" action="ZenCodingPrevAction"/> <menuitem name="ZenCodingNext" action="ZenCodingNextAction"/> <separator/> <menuitem name="ZenCodingRemove" action="ZenCodingRemoveAction"/> <menuitem name="ZenCodingSplit" action="ZenCodingSplitAction"/> <menuitem name="ZenCodingComment" action="ZenCodingCommentAction"/> </menu> </placeholder> </menu> </menubar> </ui> """ class ZenCodingPlugin(pluma.Plugin): """A Pluma plugin to implement Zen Coding's HTML and CSS shorthand expander.""" def activate(self, window): actions = [ ('ZenCodingMenuAction', None, '_Zen Coding', None, "Zen Coding tools", None), ('ZenCodingExpandAction', None, '_Expand abbreviation', '<Ctrl>E', "Expand abbreviation to raw HTML/CSS", self.expand_abbreviation), ('ZenCodingExpandWAction', None, 'E_xpand dynamic abbreviation...', '<Ctrl><Alt>E', "Dynamically expand abbreviation as you type", self.expand_with_abbreviation), ('ZenCodingWrapAction', None, '_Wrap with abbreviation...', '<Ctrl><Shift>E', "Wrap with code expanded from abbreviation", self.wrap_with_abbreviation), ('ZenCodingInwardAction', None, 'Balance tag _inward', '<Ctrl><Alt>I', "Select inner tag's content", self.match_pair_inward), ('ZenCodingOutwardAction', None, 'Balance tag _outward', '<Ctrl><Alt>O', "Select outer tag's content", self.match_pair_outward), ('ZenCodingMergeAction', None, '_Merge lines', '<Ctrl><Alt>M', "Merge all lines of the current selection", self.merge_lines), ('ZenCodingPrevAction', None, '_Previous edit point', '<Alt>Left', "Place the cursor at the previous edit point", self.prev_edit_point), ('ZenCodingNextAction', None, '_Next edit point', '<Alt>Right', "Place the cursor at the next edit point", self.next_edit_point), ('ZenCodingRemoveAction', None, '_Remove tag', '<Ctrl><Alt>R', "Remove a tag", self.remove_tag), ('ZenCodingSplitAction', None, 'Split or _join tag', '<Ctrl><Alt>J', "Toggle between single and double tag", self.split_join_tag), ('ZenCodingCommentAction', None, 'Toggle _comment', '<Ctrl><Alt>C', "Toggle an XML or HTML comment", self.toggle_comment) ] windowdata = dict() window.set_data("ZenCodingPluginDataKey", windowdata) windowdata["action_group"] = gtk.ActionGroup("PlumaZenCodingPluginActions") windowdata["action_group"].add_actions(actions, window) manager = window.get_ui_manager() manager.insert_action_group(windowdata["action_group"], -1) windowdata["ui_id"] = manager.add_ui_from_string(zencoding_ui_str) window.set_data("ZenCodingPluginInfo", windowdata) self.editor = ZenEditor() error = self.editor.get_user_settings_error() if error: md = gtk.MessageDialog(window, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE, "There is an error in user settings:") message = "{0} on line {1} at character {2}\n\nUser settings will not be available." md.set_title("Zen Coding error") md.format_secondary_text(message.format(error['msg'], error['lineno'], error['offset'])) md.run() md.destroy() def deactivate(self, window): windowdata = window.get_data("ZenCodingPluginDataKey") manager = window.get_ui_manager() manager.remove_ui(windowdata["ui_id"]) manager.remove_action_group(windowdata["action_group"]) def update_ui(self, window): view = window.get_active_view() windowdata = window.get_data("ZenCodingPluginDataKey") windowdata["action_group"].set_sensitive(bool(view and view.get_editable())) def expand_abbreviation(self, action, window): self.editor.expand_abbreviation(window) def expand_with_abbreviation(self, action, window): self.editor.expand_with_abbreviation(window) def wrap_with_abbreviation(self, action, window): self.editor.wrap_with_abbreviation(window) def match_pair_inward(self, action, window): self.editor.match_pair_inward(window) def match_pair_outward(self, action, window): self.editor.match_pair_outward(window) def merge_lines(self, action, window): self.editor.merge_lines(window) def prev_edit_point(self, action, window): self.editor.prev_edit_point(window) def next_edit_point(self, action, window): self.editor.next_edit_point(window) def remove_tag(self, action, window): <|fim_middle|> def split_join_tag(self, action, window): self.editor.split_join_tag(window) def toggle_comment(self, action, window): self.editor.toggle_comment(window) <|fim▁end|>
self.editor.remove_tag(window)
<|file_name|>plugin.py<|end_file_name|><|fim▁begin|># @file plugin.py # # Connect Zen Coding to Pluma. # # Adapted to pluma by Joao Manoel ([email protected]) # # Original Author Franck Marcia ([email protected]) # import pluma, gobject, gtk, os from zen_editor import ZenEditor zencoding_ui_str = """ <ui> <menubar name="MenuBar"> <menu name="EditMenu" action="Edit"> <placeholder name="EditOps_5"> <menu action="ZenCodingMenuAction"> <menuitem name="ZenCodingExpand" action="ZenCodingExpandAction"/> <menuitem name="ZenCodingExpandW" action="ZenCodingExpandWAction"/> <menuitem name="ZenCodingWrap" action="ZenCodingWrapAction"/> <separator/> <menuitem name="ZenCodingInward" action="ZenCodingInwardAction"/> <menuitem name="ZenCodingOutward" action="ZenCodingOutwardAction"/> <menuitem name="ZenCodingMerge" action="ZenCodingMergeAction"/> <separator/> <menuitem name="ZenCodingPrev" action="ZenCodingPrevAction"/> <menuitem name="ZenCodingNext" action="ZenCodingNextAction"/> <separator/> <menuitem name="ZenCodingRemove" action="ZenCodingRemoveAction"/> <menuitem name="ZenCodingSplit" action="ZenCodingSplitAction"/> <menuitem name="ZenCodingComment" action="ZenCodingCommentAction"/> </menu> </placeholder> </menu> </menubar> </ui> """ class ZenCodingPlugin(pluma.Plugin): """A Pluma plugin to implement Zen Coding's HTML and CSS shorthand expander.""" def activate(self, window): actions = [ ('ZenCodingMenuAction', None, '_Zen Coding', None, "Zen Coding tools", None), ('ZenCodingExpandAction', None, '_Expand abbreviation', '<Ctrl>E', "Expand abbreviation to raw HTML/CSS", self.expand_abbreviation), ('ZenCodingExpandWAction', None, 'E_xpand dynamic abbreviation...', '<Ctrl><Alt>E', "Dynamically expand abbreviation as you type", self.expand_with_abbreviation), ('ZenCodingWrapAction', None, '_Wrap with abbreviation...', '<Ctrl><Shift>E', "Wrap with code expanded from abbreviation", self.wrap_with_abbreviation), ('ZenCodingInwardAction', None, 'Balance tag _inward', '<Ctrl><Alt>I', "Select inner tag's content", self.match_pair_inward), ('ZenCodingOutwardAction', None, 'Balance tag _outward', '<Ctrl><Alt>O', "Select outer tag's content", self.match_pair_outward), ('ZenCodingMergeAction', None, '_Merge lines', '<Ctrl><Alt>M', "Merge all lines of the current selection", self.merge_lines), ('ZenCodingPrevAction', None, '_Previous edit point', '<Alt>Left', "Place the cursor at the previous edit point", self.prev_edit_point), ('ZenCodingNextAction', None, '_Next edit point', '<Alt>Right', "Place the cursor at the next edit point", self.next_edit_point), ('ZenCodingRemoveAction', None, '_Remove tag', '<Ctrl><Alt>R', "Remove a tag", self.remove_tag), ('ZenCodingSplitAction', None, 'Split or _join tag', '<Ctrl><Alt>J', "Toggle between single and double tag", self.split_join_tag), ('ZenCodingCommentAction', None, 'Toggle _comment', '<Ctrl><Alt>C', "Toggle an XML or HTML comment", self.toggle_comment) ] windowdata = dict() window.set_data("ZenCodingPluginDataKey", windowdata) windowdata["action_group"] = gtk.ActionGroup("PlumaZenCodingPluginActions") windowdata["action_group"].add_actions(actions, window) manager = window.get_ui_manager() manager.insert_action_group(windowdata["action_group"], -1) windowdata["ui_id"] = manager.add_ui_from_string(zencoding_ui_str) window.set_data("ZenCodingPluginInfo", windowdata) self.editor = ZenEditor() error = self.editor.get_user_settings_error() if error: md = gtk.MessageDialog(window, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE, "There is an error in user settings:") message = "{0} on line {1} at character {2}\n\nUser settings will not be available." md.set_title("Zen Coding error") md.format_secondary_text(message.format(error['msg'], error['lineno'], error['offset'])) md.run() md.destroy() def deactivate(self, window): windowdata = window.get_data("ZenCodingPluginDataKey") manager = window.get_ui_manager() manager.remove_ui(windowdata["ui_id"]) manager.remove_action_group(windowdata["action_group"]) def update_ui(self, window): view = window.get_active_view() windowdata = window.get_data("ZenCodingPluginDataKey") windowdata["action_group"].set_sensitive(bool(view and view.get_editable())) def expand_abbreviation(self, action, window): self.editor.expand_abbreviation(window) def expand_with_abbreviation(self, action, window): self.editor.expand_with_abbreviation(window) def wrap_with_abbreviation(self, action, window): self.editor.wrap_with_abbreviation(window) def match_pair_inward(self, action, window): self.editor.match_pair_inward(window) def match_pair_outward(self, action, window): self.editor.match_pair_outward(window) def merge_lines(self, action, window): self.editor.merge_lines(window) def prev_edit_point(self, action, window): self.editor.prev_edit_point(window) def next_edit_point(self, action, window): self.editor.next_edit_point(window) def remove_tag(self, action, window): self.editor.remove_tag(window) def split_join_tag(self, action, window): <|fim_middle|> def toggle_comment(self, action, window): self.editor.toggle_comment(window) <|fim▁end|>
self.editor.split_join_tag(window)
<|file_name|>plugin.py<|end_file_name|><|fim▁begin|># @file plugin.py # # Connect Zen Coding to Pluma. # # Adapted to pluma by Joao Manoel ([email protected]) # # Original Author Franck Marcia ([email protected]) # import pluma, gobject, gtk, os from zen_editor import ZenEditor zencoding_ui_str = """ <ui> <menubar name="MenuBar"> <menu name="EditMenu" action="Edit"> <placeholder name="EditOps_5"> <menu action="ZenCodingMenuAction"> <menuitem name="ZenCodingExpand" action="ZenCodingExpandAction"/> <menuitem name="ZenCodingExpandW" action="ZenCodingExpandWAction"/> <menuitem name="ZenCodingWrap" action="ZenCodingWrapAction"/> <separator/> <menuitem name="ZenCodingInward" action="ZenCodingInwardAction"/> <menuitem name="ZenCodingOutward" action="ZenCodingOutwardAction"/> <menuitem name="ZenCodingMerge" action="ZenCodingMergeAction"/> <separator/> <menuitem name="ZenCodingPrev" action="ZenCodingPrevAction"/> <menuitem name="ZenCodingNext" action="ZenCodingNextAction"/> <separator/> <menuitem name="ZenCodingRemove" action="ZenCodingRemoveAction"/> <menuitem name="ZenCodingSplit" action="ZenCodingSplitAction"/> <menuitem name="ZenCodingComment" action="ZenCodingCommentAction"/> </menu> </placeholder> </menu> </menubar> </ui> """ class ZenCodingPlugin(pluma.Plugin): """A Pluma plugin to implement Zen Coding's HTML and CSS shorthand expander.""" def activate(self, window): actions = [ ('ZenCodingMenuAction', None, '_Zen Coding', None, "Zen Coding tools", None), ('ZenCodingExpandAction', None, '_Expand abbreviation', '<Ctrl>E', "Expand abbreviation to raw HTML/CSS", self.expand_abbreviation), ('ZenCodingExpandWAction', None, 'E_xpand dynamic abbreviation...', '<Ctrl><Alt>E', "Dynamically expand abbreviation as you type", self.expand_with_abbreviation), ('ZenCodingWrapAction', None, '_Wrap with abbreviation...', '<Ctrl><Shift>E', "Wrap with code expanded from abbreviation", self.wrap_with_abbreviation), ('ZenCodingInwardAction', None, 'Balance tag _inward', '<Ctrl><Alt>I', "Select inner tag's content", self.match_pair_inward), ('ZenCodingOutwardAction', None, 'Balance tag _outward', '<Ctrl><Alt>O', "Select outer tag's content", self.match_pair_outward), ('ZenCodingMergeAction', None, '_Merge lines', '<Ctrl><Alt>M', "Merge all lines of the current selection", self.merge_lines), ('ZenCodingPrevAction', None, '_Previous edit point', '<Alt>Left', "Place the cursor at the previous edit point", self.prev_edit_point), ('ZenCodingNextAction', None, '_Next edit point', '<Alt>Right', "Place the cursor at the next edit point", self.next_edit_point), ('ZenCodingRemoveAction', None, '_Remove tag', '<Ctrl><Alt>R', "Remove a tag", self.remove_tag), ('ZenCodingSplitAction', None, 'Split or _join tag', '<Ctrl><Alt>J', "Toggle between single and double tag", self.split_join_tag), ('ZenCodingCommentAction', None, 'Toggle _comment', '<Ctrl><Alt>C', "Toggle an XML or HTML comment", self.toggle_comment) ] windowdata = dict() window.set_data("ZenCodingPluginDataKey", windowdata) windowdata["action_group"] = gtk.ActionGroup("PlumaZenCodingPluginActions") windowdata["action_group"].add_actions(actions, window) manager = window.get_ui_manager() manager.insert_action_group(windowdata["action_group"], -1) windowdata["ui_id"] = manager.add_ui_from_string(zencoding_ui_str) window.set_data("ZenCodingPluginInfo", windowdata) self.editor = ZenEditor() error = self.editor.get_user_settings_error() if error: md = gtk.MessageDialog(window, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE, "There is an error in user settings:") message = "{0} on line {1} at character {2}\n\nUser settings will not be available." md.set_title("Zen Coding error") md.format_secondary_text(message.format(error['msg'], error['lineno'], error['offset'])) md.run() md.destroy() def deactivate(self, window): windowdata = window.get_data("ZenCodingPluginDataKey") manager = window.get_ui_manager() manager.remove_ui(windowdata["ui_id"]) manager.remove_action_group(windowdata["action_group"]) def update_ui(self, window): view = window.get_active_view() windowdata = window.get_data("ZenCodingPluginDataKey") windowdata["action_group"].set_sensitive(bool(view and view.get_editable())) def expand_abbreviation(self, action, window): self.editor.expand_abbreviation(window) def expand_with_abbreviation(self, action, window): self.editor.expand_with_abbreviation(window) def wrap_with_abbreviation(self, action, window): self.editor.wrap_with_abbreviation(window) def match_pair_inward(self, action, window): self.editor.match_pair_inward(window) def match_pair_outward(self, action, window): self.editor.match_pair_outward(window) def merge_lines(self, action, window): self.editor.merge_lines(window) def prev_edit_point(self, action, window): self.editor.prev_edit_point(window) def next_edit_point(self, action, window): self.editor.next_edit_point(window) def remove_tag(self, action, window): self.editor.remove_tag(window) def split_join_tag(self, action, window): self.editor.split_join_tag(window) def toggle_comment(self, action, window): <|fim_middle|> <|fim▁end|>
self.editor.toggle_comment(window)
<|file_name|>plugin.py<|end_file_name|><|fim▁begin|># @file plugin.py # # Connect Zen Coding to Pluma. # # Adapted to pluma by Joao Manoel ([email protected]) # # Original Author Franck Marcia ([email protected]) # import pluma, gobject, gtk, os from zen_editor import ZenEditor zencoding_ui_str = """ <ui> <menubar name="MenuBar"> <menu name="EditMenu" action="Edit"> <placeholder name="EditOps_5"> <menu action="ZenCodingMenuAction"> <menuitem name="ZenCodingExpand" action="ZenCodingExpandAction"/> <menuitem name="ZenCodingExpandW" action="ZenCodingExpandWAction"/> <menuitem name="ZenCodingWrap" action="ZenCodingWrapAction"/> <separator/> <menuitem name="ZenCodingInward" action="ZenCodingInwardAction"/> <menuitem name="ZenCodingOutward" action="ZenCodingOutwardAction"/> <menuitem name="ZenCodingMerge" action="ZenCodingMergeAction"/> <separator/> <menuitem name="ZenCodingPrev" action="ZenCodingPrevAction"/> <menuitem name="ZenCodingNext" action="ZenCodingNextAction"/> <separator/> <menuitem name="ZenCodingRemove" action="ZenCodingRemoveAction"/> <menuitem name="ZenCodingSplit" action="ZenCodingSplitAction"/> <menuitem name="ZenCodingComment" action="ZenCodingCommentAction"/> </menu> </placeholder> </menu> </menubar> </ui> """ class ZenCodingPlugin(pluma.Plugin): """A Pluma plugin to implement Zen Coding's HTML and CSS shorthand expander.""" def <|fim_middle|>(self, window): actions = [ ('ZenCodingMenuAction', None, '_Zen Coding', None, "Zen Coding tools", None), ('ZenCodingExpandAction', None, '_Expand abbreviation', '<Ctrl>E', "Expand abbreviation to raw HTML/CSS", self.expand_abbreviation), ('ZenCodingExpandWAction', None, 'E_xpand dynamic abbreviation...', '<Ctrl><Alt>E', "Dynamically expand abbreviation as you type", self.expand_with_abbreviation), ('ZenCodingWrapAction', None, '_Wrap with abbreviation...', '<Ctrl><Shift>E', "Wrap with code expanded from abbreviation", self.wrap_with_abbreviation), ('ZenCodingInwardAction', None, 'Balance tag _inward', '<Ctrl><Alt>I', "Select inner tag's content", self.match_pair_inward), ('ZenCodingOutwardAction', None, 'Balance tag _outward', '<Ctrl><Alt>O', "Select outer tag's content", self.match_pair_outward), ('ZenCodingMergeAction', None, '_Merge lines', '<Ctrl><Alt>M', "Merge all lines of the current selection", self.merge_lines), ('ZenCodingPrevAction', None, '_Previous edit point', '<Alt>Left', "Place the cursor at the previous edit point", self.prev_edit_point), ('ZenCodingNextAction', None, '_Next edit point', '<Alt>Right', "Place the cursor at the next edit point", self.next_edit_point), ('ZenCodingRemoveAction', None, '_Remove tag', '<Ctrl><Alt>R', "Remove a tag", self.remove_tag), ('ZenCodingSplitAction', None, 'Split or _join tag', '<Ctrl><Alt>J', "Toggle between single and double tag", self.split_join_tag), ('ZenCodingCommentAction', None, 'Toggle _comment', '<Ctrl><Alt>C', "Toggle an XML or HTML comment", self.toggle_comment) ] windowdata = dict() window.set_data("ZenCodingPluginDataKey", windowdata) windowdata["action_group"] = gtk.ActionGroup("PlumaZenCodingPluginActions") windowdata["action_group"].add_actions(actions, window) manager = window.get_ui_manager() manager.insert_action_group(windowdata["action_group"], -1) windowdata["ui_id"] = manager.add_ui_from_string(zencoding_ui_str) window.set_data("ZenCodingPluginInfo", windowdata) self.editor = ZenEditor() error = self.editor.get_user_settings_error() if error: md = gtk.MessageDialog(window, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE, "There is an error in user settings:") message = "{0} on line {1} at character {2}\n\nUser settings will not be available." md.set_title("Zen Coding error") md.format_secondary_text(message.format(error['msg'], error['lineno'], error['offset'])) md.run() md.destroy() def deactivate(self, window): windowdata = window.get_data("ZenCodingPluginDataKey") manager = window.get_ui_manager() manager.remove_ui(windowdata["ui_id"]) manager.remove_action_group(windowdata["action_group"]) def update_ui(self, window): view = window.get_active_view() windowdata = window.get_data("ZenCodingPluginDataKey") windowdata["action_group"].set_sensitive(bool(view and view.get_editable())) def expand_abbreviation(self, action, window): self.editor.expand_abbreviation(window) def expand_with_abbreviation(self, action, window): self.editor.expand_with_abbreviation(window) def wrap_with_abbreviation(self, action, window): self.editor.wrap_with_abbreviation(window) def match_pair_inward(self, action, window): self.editor.match_pair_inward(window) def match_pair_outward(self, action, window): self.editor.match_pair_outward(window) def merge_lines(self, action, window): self.editor.merge_lines(window) def prev_edit_point(self, action, window): self.editor.prev_edit_point(window) def next_edit_point(self, action, window): self.editor.next_edit_point(window) def remove_tag(self, action, window): self.editor.remove_tag(window) def split_join_tag(self, action, window): self.editor.split_join_tag(window) def toggle_comment(self, action, window): self.editor.toggle_comment(window) <|fim▁end|>
activate
<|file_name|>plugin.py<|end_file_name|><|fim▁begin|># @file plugin.py # # Connect Zen Coding to Pluma. # # Adapted to pluma by Joao Manoel ([email protected]) # # Original Author Franck Marcia ([email protected]) # import pluma, gobject, gtk, os from zen_editor import ZenEditor zencoding_ui_str = """ <ui> <menubar name="MenuBar"> <menu name="EditMenu" action="Edit"> <placeholder name="EditOps_5"> <menu action="ZenCodingMenuAction"> <menuitem name="ZenCodingExpand" action="ZenCodingExpandAction"/> <menuitem name="ZenCodingExpandW" action="ZenCodingExpandWAction"/> <menuitem name="ZenCodingWrap" action="ZenCodingWrapAction"/> <separator/> <menuitem name="ZenCodingInward" action="ZenCodingInwardAction"/> <menuitem name="ZenCodingOutward" action="ZenCodingOutwardAction"/> <menuitem name="ZenCodingMerge" action="ZenCodingMergeAction"/> <separator/> <menuitem name="ZenCodingPrev" action="ZenCodingPrevAction"/> <menuitem name="ZenCodingNext" action="ZenCodingNextAction"/> <separator/> <menuitem name="ZenCodingRemove" action="ZenCodingRemoveAction"/> <menuitem name="ZenCodingSplit" action="ZenCodingSplitAction"/> <menuitem name="ZenCodingComment" action="ZenCodingCommentAction"/> </menu> </placeholder> </menu> </menubar> </ui> """ class ZenCodingPlugin(pluma.Plugin): """A Pluma plugin to implement Zen Coding's HTML and CSS shorthand expander.""" def activate(self, window): actions = [ ('ZenCodingMenuAction', None, '_Zen Coding', None, "Zen Coding tools", None), ('ZenCodingExpandAction', None, '_Expand abbreviation', '<Ctrl>E', "Expand abbreviation to raw HTML/CSS", self.expand_abbreviation), ('ZenCodingExpandWAction', None, 'E_xpand dynamic abbreviation...', '<Ctrl><Alt>E', "Dynamically expand abbreviation as you type", self.expand_with_abbreviation), ('ZenCodingWrapAction', None, '_Wrap with abbreviation...', '<Ctrl><Shift>E', "Wrap with code expanded from abbreviation", self.wrap_with_abbreviation), ('ZenCodingInwardAction', None, 'Balance tag _inward', '<Ctrl><Alt>I', "Select inner tag's content", self.match_pair_inward), ('ZenCodingOutwardAction', None, 'Balance tag _outward', '<Ctrl><Alt>O', "Select outer tag's content", self.match_pair_outward), ('ZenCodingMergeAction', None, '_Merge lines', '<Ctrl><Alt>M', "Merge all lines of the current selection", self.merge_lines), ('ZenCodingPrevAction', None, '_Previous edit point', '<Alt>Left', "Place the cursor at the previous edit point", self.prev_edit_point), ('ZenCodingNextAction', None, '_Next edit point', '<Alt>Right', "Place the cursor at the next edit point", self.next_edit_point), ('ZenCodingRemoveAction', None, '_Remove tag', '<Ctrl><Alt>R', "Remove a tag", self.remove_tag), ('ZenCodingSplitAction', None, 'Split or _join tag', '<Ctrl><Alt>J', "Toggle between single and double tag", self.split_join_tag), ('ZenCodingCommentAction', None, 'Toggle _comment', '<Ctrl><Alt>C', "Toggle an XML or HTML comment", self.toggle_comment) ] windowdata = dict() window.set_data("ZenCodingPluginDataKey", windowdata) windowdata["action_group"] = gtk.ActionGroup("PlumaZenCodingPluginActions") windowdata["action_group"].add_actions(actions, window) manager = window.get_ui_manager() manager.insert_action_group(windowdata["action_group"], -1) windowdata["ui_id"] = manager.add_ui_from_string(zencoding_ui_str) window.set_data("ZenCodingPluginInfo", windowdata) self.editor = ZenEditor() error = self.editor.get_user_settings_error() if error: md = gtk.MessageDialog(window, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE, "There is an error in user settings:") message = "{0} on line {1} at character {2}\n\nUser settings will not be available." md.set_title("Zen Coding error") md.format_secondary_text(message.format(error['msg'], error['lineno'], error['offset'])) md.run() md.destroy() def <|fim_middle|>(self, window): windowdata = window.get_data("ZenCodingPluginDataKey") manager = window.get_ui_manager() manager.remove_ui(windowdata["ui_id"]) manager.remove_action_group(windowdata["action_group"]) def update_ui(self, window): view = window.get_active_view() windowdata = window.get_data("ZenCodingPluginDataKey") windowdata["action_group"].set_sensitive(bool(view and view.get_editable())) def expand_abbreviation(self, action, window): self.editor.expand_abbreviation(window) def expand_with_abbreviation(self, action, window): self.editor.expand_with_abbreviation(window) def wrap_with_abbreviation(self, action, window): self.editor.wrap_with_abbreviation(window) def match_pair_inward(self, action, window): self.editor.match_pair_inward(window) def match_pair_outward(self, action, window): self.editor.match_pair_outward(window) def merge_lines(self, action, window): self.editor.merge_lines(window) def prev_edit_point(self, action, window): self.editor.prev_edit_point(window) def next_edit_point(self, action, window): self.editor.next_edit_point(window) def remove_tag(self, action, window): self.editor.remove_tag(window) def split_join_tag(self, action, window): self.editor.split_join_tag(window) def toggle_comment(self, action, window): self.editor.toggle_comment(window) <|fim▁end|>
deactivate
<|file_name|>plugin.py<|end_file_name|><|fim▁begin|># @file plugin.py # # Connect Zen Coding to Pluma. # # Adapted to pluma by Joao Manoel ([email protected]) # # Original Author Franck Marcia ([email protected]) # import pluma, gobject, gtk, os from zen_editor import ZenEditor zencoding_ui_str = """ <ui> <menubar name="MenuBar"> <menu name="EditMenu" action="Edit"> <placeholder name="EditOps_5"> <menu action="ZenCodingMenuAction"> <menuitem name="ZenCodingExpand" action="ZenCodingExpandAction"/> <menuitem name="ZenCodingExpandW" action="ZenCodingExpandWAction"/> <menuitem name="ZenCodingWrap" action="ZenCodingWrapAction"/> <separator/> <menuitem name="ZenCodingInward" action="ZenCodingInwardAction"/> <menuitem name="ZenCodingOutward" action="ZenCodingOutwardAction"/> <menuitem name="ZenCodingMerge" action="ZenCodingMergeAction"/> <separator/> <menuitem name="ZenCodingPrev" action="ZenCodingPrevAction"/> <menuitem name="ZenCodingNext" action="ZenCodingNextAction"/> <separator/> <menuitem name="ZenCodingRemove" action="ZenCodingRemoveAction"/> <menuitem name="ZenCodingSplit" action="ZenCodingSplitAction"/> <menuitem name="ZenCodingComment" action="ZenCodingCommentAction"/> </menu> </placeholder> </menu> </menubar> </ui> """ class ZenCodingPlugin(pluma.Plugin): """A Pluma plugin to implement Zen Coding's HTML and CSS shorthand expander.""" def activate(self, window): actions = [ ('ZenCodingMenuAction', None, '_Zen Coding', None, "Zen Coding tools", None), ('ZenCodingExpandAction', None, '_Expand abbreviation', '<Ctrl>E', "Expand abbreviation to raw HTML/CSS", self.expand_abbreviation), ('ZenCodingExpandWAction', None, 'E_xpand dynamic abbreviation...', '<Ctrl><Alt>E', "Dynamically expand abbreviation as you type", self.expand_with_abbreviation), ('ZenCodingWrapAction', None, '_Wrap with abbreviation...', '<Ctrl><Shift>E', "Wrap with code expanded from abbreviation", self.wrap_with_abbreviation), ('ZenCodingInwardAction', None, 'Balance tag _inward', '<Ctrl><Alt>I', "Select inner tag's content", self.match_pair_inward), ('ZenCodingOutwardAction', None, 'Balance tag _outward', '<Ctrl><Alt>O', "Select outer tag's content", self.match_pair_outward), ('ZenCodingMergeAction', None, '_Merge lines', '<Ctrl><Alt>M', "Merge all lines of the current selection", self.merge_lines), ('ZenCodingPrevAction', None, '_Previous edit point', '<Alt>Left', "Place the cursor at the previous edit point", self.prev_edit_point), ('ZenCodingNextAction', None, '_Next edit point', '<Alt>Right', "Place the cursor at the next edit point", self.next_edit_point), ('ZenCodingRemoveAction', None, '_Remove tag', '<Ctrl><Alt>R', "Remove a tag", self.remove_tag), ('ZenCodingSplitAction', None, 'Split or _join tag', '<Ctrl><Alt>J', "Toggle between single and double tag", self.split_join_tag), ('ZenCodingCommentAction', None, 'Toggle _comment', '<Ctrl><Alt>C', "Toggle an XML or HTML comment", self.toggle_comment) ] windowdata = dict() window.set_data("ZenCodingPluginDataKey", windowdata) windowdata["action_group"] = gtk.ActionGroup("PlumaZenCodingPluginActions") windowdata["action_group"].add_actions(actions, window) manager = window.get_ui_manager() manager.insert_action_group(windowdata["action_group"], -1) windowdata["ui_id"] = manager.add_ui_from_string(zencoding_ui_str) window.set_data("ZenCodingPluginInfo", windowdata) self.editor = ZenEditor() error = self.editor.get_user_settings_error() if error: md = gtk.MessageDialog(window, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE, "There is an error in user settings:") message = "{0} on line {1} at character {2}\n\nUser settings will not be available." md.set_title("Zen Coding error") md.format_secondary_text(message.format(error['msg'], error['lineno'], error['offset'])) md.run() md.destroy() def deactivate(self, window): windowdata = window.get_data("ZenCodingPluginDataKey") manager = window.get_ui_manager() manager.remove_ui(windowdata["ui_id"]) manager.remove_action_group(windowdata["action_group"]) def <|fim_middle|>(self, window): view = window.get_active_view() windowdata = window.get_data("ZenCodingPluginDataKey") windowdata["action_group"].set_sensitive(bool(view and view.get_editable())) def expand_abbreviation(self, action, window): self.editor.expand_abbreviation(window) def expand_with_abbreviation(self, action, window): self.editor.expand_with_abbreviation(window) def wrap_with_abbreviation(self, action, window): self.editor.wrap_with_abbreviation(window) def match_pair_inward(self, action, window): self.editor.match_pair_inward(window) def match_pair_outward(self, action, window): self.editor.match_pair_outward(window) def merge_lines(self, action, window): self.editor.merge_lines(window) def prev_edit_point(self, action, window): self.editor.prev_edit_point(window) def next_edit_point(self, action, window): self.editor.next_edit_point(window) def remove_tag(self, action, window): self.editor.remove_tag(window) def split_join_tag(self, action, window): self.editor.split_join_tag(window) def toggle_comment(self, action, window): self.editor.toggle_comment(window) <|fim▁end|>
update_ui
<|file_name|>plugin.py<|end_file_name|><|fim▁begin|># @file plugin.py # # Connect Zen Coding to Pluma. # # Adapted to pluma by Joao Manoel ([email protected]) # # Original Author Franck Marcia ([email protected]) # import pluma, gobject, gtk, os from zen_editor import ZenEditor zencoding_ui_str = """ <ui> <menubar name="MenuBar"> <menu name="EditMenu" action="Edit"> <placeholder name="EditOps_5"> <menu action="ZenCodingMenuAction"> <menuitem name="ZenCodingExpand" action="ZenCodingExpandAction"/> <menuitem name="ZenCodingExpandW" action="ZenCodingExpandWAction"/> <menuitem name="ZenCodingWrap" action="ZenCodingWrapAction"/> <separator/> <menuitem name="ZenCodingInward" action="ZenCodingInwardAction"/> <menuitem name="ZenCodingOutward" action="ZenCodingOutwardAction"/> <menuitem name="ZenCodingMerge" action="ZenCodingMergeAction"/> <separator/> <menuitem name="ZenCodingPrev" action="ZenCodingPrevAction"/> <menuitem name="ZenCodingNext" action="ZenCodingNextAction"/> <separator/> <menuitem name="ZenCodingRemove" action="ZenCodingRemoveAction"/> <menuitem name="ZenCodingSplit" action="ZenCodingSplitAction"/> <menuitem name="ZenCodingComment" action="ZenCodingCommentAction"/> </menu> </placeholder> </menu> </menubar> </ui> """ class ZenCodingPlugin(pluma.Plugin): """A Pluma plugin to implement Zen Coding's HTML and CSS shorthand expander.""" def activate(self, window): actions = [ ('ZenCodingMenuAction', None, '_Zen Coding', None, "Zen Coding tools", None), ('ZenCodingExpandAction', None, '_Expand abbreviation', '<Ctrl>E', "Expand abbreviation to raw HTML/CSS", self.expand_abbreviation), ('ZenCodingExpandWAction', None, 'E_xpand dynamic abbreviation...', '<Ctrl><Alt>E', "Dynamically expand abbreviation as you type", self.expand_with_abbreviation), ('ZenCodingWrapAction', None, '_Wrap with abbreviation...', '<Ctrl><Shift>E', "Wrap with code expanded from abbreviation", self.wrap_with_abbreviation), ('ZenCodingInwardAction', None, 'Balance tag _inward', '<Ctrl><Alt>I', "Select inner tag's content", self.match_pair_inward), ('ZenCodingOutwardAction', None, 'Balance tag _outward', '<Ctrl><Alt>O', "Select outer tag's content", self.match_pair_outward), ('ZenCodingMergeAction', None, '_Merge lines', '<Ctrl><Alt>M', "Merge all lines of the current selection", self.merge_lines), ('ZenCodingPrevAction', None, '_Previous edit point', '<Alt>Left', "Place the cursor at the previous edit point", self.prev_edit_point), ('ZenCodingNextAction', None, '_Next edit point', '<Alt>Right', "Place the cursor at the next edit point", self.next_edit_point), ('ZenCodingRemoveAction', None, '_Remove tag', '<Ctrl><Alt>R', "Remove a tag", self.remove_tag), ('ZenCodingSplitAction', None, 'Split or _join tag', '<Ctrl><Alt>J', "Toggle between single and double tag", self.split_join_tag), ('ZenCodingCommentAction', None, 'Toggle _comment', '<Ctrl><Alt>C', "Toggle an XML or HTML comment", self.toggle_comment) ] windowdata = dict() window.set_data("ZenCodingPluginDataKey", windowdata) windowdata["action_group"] = gtk.ActionGroup("PlumaZenCodingPluginActions") windowdata["action_group"].add_actions(actions, window) manager = window.get_ui_manager() manager.insert_action_group(windowdata["action_group"], -1) windowdata["ui_id"] = manager.add_ui_from_string(zencoding_ui_str) window.set_data("ZenCodingPluginInfo", windowdata) self.editor = ZenEditor() error = self.editor.get_user_settings_error() if error: md = gtk.MessageDialog(window, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE, "There is an error in user settings:") message = "{0} on line {1} at character {2}\n\nUser settings will not be available." md.set_title("Zen Coding error") md.format_secondary_text(message.format(error['msg'], error['lineno'], error['offset'])) md.run() md.destroy() def deactivate(self, window): windowdata = window.get_data("ZenCodingPluginDataKey") manager = window.get_ui_manager() manager.remove_ui(windowdata["ui_id"]) manager.remove_action_group(windowdata["action_group"]) def update_ui(self, window): view = window.get_active_view() windowdata = window.get_data("ZenCodingPluginDataKey") windowdata["action_group"].set_sensitive(bool(view and view.get_editable())) def <|fim_middle|>(self, action, window): self.editor.expand_abbreviation(window) def expand_with_abbreviation(self, action, window): self.editor.expand_with_abbreviation(window) def wrap_with_abbreviation(self, action, window): self.editor.wrap_with_abbreviation(window) def match_pair_inward(self, action, window): self.editor.match_pair_inward(window) def match_pair_outward(self, action, window): self.editor.match_pair_outward(window) def merge_lines(self, action, window): self.editor.merge_lines(window) def prev_edit_point(self, action, window): self.editor.prev_edit_point(window) def next_edit_point(self, action, window): self.editor.next_edit_point(window) def remove_tag(self, action, window): self.editor.remove_tag(window) def split_join_tag(self, action, window): self.editor.split_join_tag(window) def toggle_comment(self, action, window): self.editor.toggle_comment(window) <|fim▁end|>
expand_abbreviation
<|file_name|>plugin.py<|end_file_name|><|fim▁begin|># @file plugin.py # # Connect Zen Coding to Pluma. # # Adapted to pluma by Joao Manoel ([email protected]) # # Original Author Franck Marcia ([email protected]) # import pluma, gobject, gtk, os from zen_editor import ZenEditor zencoding_ui_str = """ <ui> <menubar name="MenuBar"> <menu name="EditMenu" action="Edit"> <placeholder name="EditOps_5"> <menu action="ZenCodingMenuAction"> <menuitem name="ZenCodingExpand" action="ZenCodingExpandAction"/> <menuitem name="ZenCodingExpandW" action="ZenCodingExpandWAction"/> <menuitem name="ZenCodingWrap" action="ZenCodingWrapAction"/> <separator/> <menuitem name="ZenCodingInward" action="ZenCodingInwardAction"/> <menuitem name="ZenCodingOutward" action="ZenCodingOutwardAction"/> <menuitem name="ZenCodingMerge" action="ZenCodingMergeAction"/> <separator/> <menuitem name="ZenCodingPrev" action="ZenCodingPrevAction"/> <menuitem name="ZenCodingNext" action="ZenCodingNextAction"/> <separator/> <menuitem name="ZenCodingRemove" action="ZenCodingRemoveAction"/> <menuitem name="ZenCodingSplit" action="ZenCodingSplitAction"/> <menuitem name="ZenCodingComment" action="ZenCodingCommentAction"/> </menu> </placeholder> </menu> </menubar> </ui> """ class ZenCodingPlugin(pluma.Plugin): """A Pluma plugin to implement Zen Coding's HTML and CSS shorthand expander.""" def activate(self, window): actions = [ ('ZenCodingMenuAction', None, '_Zen Coding', None, "Zen Coding tools", None), ('ZenCodingExpandAction', None, '_Expand abbreviation', '<Ctrl>E', "Expand abbreviation to raw HTML/CSS", self.expand_abbreviation), ('ZenCodingExpandWAction', None, 'E_xpand dynamic abbreviation...', '<Ctrl><Alt>E', "Dynamically expand abbreviation as you type", self.expand_with_abbreviation), ('ZenCodingWrapAction', None, '_Wrap with abbreviation...', '<Ctrl><Shift>E', "Wrap with code expanded from abbreviation", self.wrap_with_abbreviation), ('ZenCodingInwardAction', None, 'Balance tag _inward', '<Ctrl><Alt>I', "Select inner tag's content", self.match_pair_inward), ('ZenCodingOutwardAction', None, 'Balance tag _outward', '<Ctrl><Alt>O', "Select outer tag's content", self.match_pair_outward), ('ZenCodingMergeAction', None, '_Merge lines', '<Ctrl><Alt>M', "Merge all lines of the current selection", self.merge_lines), ('ZenCodingPrevAction', None, '_Previous edit point', '<Alt>Left', "Place the cursor at the previous edit point", self.prev_edit_point), ('ZenCodingNextAction', None, '_Next edit point', '<Alt>Right', "Place the cursor at the next edit point", self.next_edit_point), ('ZenCodingRemoveAction', None, '_Remove tag', '<Ctrl><Alt>R', "Remove a tag", self.remove_tag), ('ZenCodingSplitAction', None, 'Split or _join tag', '<Ctrl><Alt>J', "Toggle between single and double tag", self.split_join_tag), ('ZenCodingCommentAction', None, 'Toggle _comment', '<Ctrl><Alt>C', "Toggle an XML or HTML comment", self.toggle_comment) ] windowdata = dict() window.set_data("ZenCodingPluginDataKey", windowdata) windowdata["action_group"] = gtk.ActionGroup("PlumaZenCodingPluginActions") windowdata["action_group"].add_actions(actions, window) manager = window.get_ui_manager() manager.insert_action_group(windowdata["action_group"], -1) windowdata["ui_id"] = manager.add_ui_from_string(zencoding_ui_str) window.set_data("ZenCodingPluginInfo", windowdata) self.editor = ZenEditor() error = self.editor.get_user_settings_error() if error: md = gtk.MessageDialog(window, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE, "There is an error in user settings:") message = "{0} on line {1} at character {2}\n\nUser settings will not be available." md.set_title("Zen Coding error") md.format_secondary_text(message.format(error['msg'], error['lineno'], error['offset'])) md.run() md.destroy() def deactivate(self, window): windowdata = window.get_data("ZenCodingPluginDataKey") manager = window.get_ui_manager() manager.remove_ui(windowdata["ui_id"]) manager.remove_action_group(windowdata["action_group"]) def update_ui(self, window): view = window.get_active_view() windowdata = window.get_data("ZenCodingPluginDataKey") windowdata["action_group"].set_sensitive(bool(view and view.get_editable())) def expand_abbreviation(self, action, window): self.editor.expand_abbreviation(window) def <|fim_middle|>(self, action, window): self.editor.expand_with_abbreviation(window) def wrap_with_abbreviation(self, action, window): self.editor.wrap_with_abbreviation(window) def match_pair_inward(self, action, window): self.editor.match_pair_inward(window) def match_pair_outward(self, action, window): self.editor.match_pair_outward(window) def merge_lines(self, action, window): self.editor.merge_lines(window) def prev_edit_point(self, action, window): self.editor.prev_edit_point(window) def next_edit_point(self, action, window): self.editor.next_edit_point(window) def remove_tag(self, action, window): self.editor.remove_tag(window) def split_join_tag(self, action, window): self.editor.split_join_tag(window) def toggle_comment(self, action, window): self.editor.toggle_comment(window) <|fim▁end|>
expand_with_abbreviation
<|file_name|>plugin.py<|end_file_name|><|fim▁begin|># @file plugin.py # # Connect Zen Coding to Pluma. # # Adapted to pluma by Joao Manoel ([email protected]) # # Original Author Franck Marcia ([email protected]) # import pluma, gobject, gtk, os from zen_editor import ZenEditor zencoding_ui_str = """ <ui> <menubar name="MenuBar"> <menu name="EditMenu" action="Edit"> <placeholder name="EditOps_5"> <menu action="ZenCodingMenuAction"> <menuitem name="ZenCodingExpand" action="ZenCodingExpandAction"/> <menuitem name="ZenCodingExpandW" action="ZenCodingExpandWAction"/> <menuitem name="ZenCodingWrap" action="ZenCodingWrapAction"/> <separator/> <menuitem name="ZenCodingInward" action="ZenCodingInwardAction"/> <menuitem name="ZenCodingOutward" action="ZenCodingOutwardAction"/> <menuitem name="ZenCodingMerge" action="ZenCodingMergeAction"/> <separator/> <menuitem name="ZenCodingPrev" action="ZenCodingPrevAction"/> <menuitem name="ZenCodingNext" action="ZenCodingNextAction"/> <separator/> <menuitem name="ZenCodingRemove" action="ZenCodingRemoveAction"/> <menuitem name="ZenCodingSplit" action="ZenCodingSplitAction"/> <menuitem name="ZenCodingComment" action="ZenCodingCommentAction"/> </menu> </placeholder> </menu> </menubar> </ui> """ class ZenCodingPlugin(pluma.Plugin): """A Pluma plugin to implement Zen Coding's HTML and CSS shorthand expander.""" def activate(self, window): actions = [ ('ZenCodingMenuAction', None, '_Zen Coding', None, "Zen Coding tools", None), ('ZenCodingExpandAction', None, '_Expand abbreviation', '<Ctrl>E', "Expand abbreviation to raw HTML/CSS", self.expand_abbreviation), ('ZenCodingExpandWAction', None, 'E_xpand dynamic abbreviation...', '<Ctrl><Alt>E', "Dynamically expand abbreviation as you type", self.expand_with_abbreviation), ('ZenCodingWrapAction', None, '_Wrap with abbreviation...', '<Ctrl><Shift>E', "Wrap with code expanded from abbreviation", self.wrap_with_abbreviation), ('ZenCodingInwardAction', None, 'Balance tag _inward', '<Ctrl><Alt>I', "Select inner tag's content", self.match_pair_inward), ('ZenCodingOutwardAction', None, 'Balance tag _outward', '<Ctrl><Alt>O', "Select outer tag's content", self.match_pair_outward), ('ZenCodingMergeAction', None, '_Merge lines', '<Ctrl><Alt>M', "Merge all lines of the current selection", self.merge_lines), ('ZenCodingPrevAction', None, '_Previous edit point', '<Alt>Left', "Place the cursor at the previous edit point", self.prev_edit_point), ('ZenCodingNextAction', None, '_Next edit point', '<Alt>Right', "Place the cursor at the next edit point", self.next_edit_point), ('ZenCodingRemoveAction', None, '_Remove tag', '<Ctrl><Alt>R', "Remove a tag", self.remove_tag), ('ZenCodingSplitAction', None, 'Split or _join tag', '<Ctrl><Alt>J', "Toggle between single and double tag", self.split_join_tag), ('ZenCodingCommentAction', None, 'Toggle _comment', '<Ctrl><Alt>C', "Toggle an XML or HTML comment", self.toggle_comment) ] windowdata = dict() window.set_data("ZenCodingPluginDataKey", windowdata) windowdata["action_group"] = gtk.ActionGroup("PlumaZenCodingPluginActions") windowdata["action_group"].add_actions(actions, window) manager = window.get_ui_manager() manager.insert_action_group(windowdata["action_group"], -1) windowdata["ui_id"] = manager.add_ui_from_string(zencoding_ui_str) window.set_data("ZenCodingPluginInfo", windowdata) self.editor = ZenEditor() error = self.editor.get_user_settings_error() if error: md = gtk.MessageDialog(window, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE, "There is an error in user settings:") message = "{0} on line {1} at character {2}\n\nUser settings will not be available." md.set_title("Zen Coding error") md.format_secondary_text(message.format(error['msg'], error['lineno'], error['offset'])) md.run() md.destroy() def deactivate(self, window): windowdata = window.get_data("ZenCodingPluginDataKey") manager = window.get_ui_manager() manager.remove_ui(windowdata["ui_id"]) manager.remove_action_group(windowdata["action_group"]) def update_ui(self, window): view = window.get_active_view() windowdata = window.get_data("ZenCodingPluginDataKey") windowdata["action_group"].set_sensitive(bool(view and view.get_editable())) def expand_abbreviation(self, action, window): self.editor.expand_abbreviation(window) def expand_with_abbreviation(self, action, window): self.editor.expand_with_abbreviation(window) def <|fim_middle|>(self, action, window): self.editor.wrap_with_abbreviation(window) def match_pair_inward(self, action, window): self.editor.match_pair_inward(window) def match_pair_outward(self, action, window): self.editor.match_pair_outward(window) def merge_lines(self, action, window): self.editor.merge_lines(window) def prev_edit_point(self, action, window): self.editor.prev_edit_point(window) def next_edit_point(self, action, window): self.editor.next_edit_point(window) def remove_tag(self, action, window): self.editor.remove_tag(window) def split_join_tag(self, action, window): self.editor.split_join_tag(window) def toggle_comment(self, action, window): self.editor.toggle_comment(window) <|fim▁end|>
wrap_with_abbreviation
<|file_name|>plugin.py<|end_file_name|><|fim▁begin|># @file plugin.py # # Connect Zen Coding to Pluma. # # Adapted to pluma by Joao Manoel ([email protected]) # # Original Author Franck Marcia ([email protected]) # import pluma, gobject, gtk, os from zen_editor import ZenEditor zencoding_ui_str = """ <ui> <menubar name="MenuBar"> <menu name="EditMenu" action="Edit"> <placeholder name="EditOps_5"> <menu action="ZenCodingMenuAction"> <menuitem name="ZenCodingExpand" action="ZenCodingExpandAction"/> <menuitem name="ZenCodingExpandW" action="ZenCodingExpandWAction"/> <menuitem name="ZenCodingWrap" action="ZenCodingWrapAction"/> <separator/> <menuitem name="ZenCodingInward" action="ZenCodingInwardAction"/> <menuitem name="ZenCodingOutward" action="ZenCodingOutwardAction"/> <menuitem name="ZenCodingMerge" action="ZenCodingMergeAction"/> <separator/> <menuitem name="ZenCodingPrev" action="ZenCodingPrevAction"/> <menuitem name="ZenCodingNext" action="ZenCodingNextAction"/> <separator/> <menuitem name="ZenCodingRemove" action="ZenCodingRemoveAction"/> <menuitem name="ZenCodingSplit" action="ZenCodingSplitAction"/> <menuitem name="ZenCodingComment" action="ZenCodingCommentAction"/> </menu> </placeholder> </menu> </menubar> </ui> """ class ZenCodingPlugin(pluma.Plugin): """A Pluma plugin to implement Zen Coding's HTML and CSS shorthand expander.""" def activate(self, window): actions = [ ('ZenCodingMenuAction', None, '_Zen Coding', None, "Zen Coding tools", None), ('ZenCodingExpandAction', None, '_Expand abbreviation', '<Ctrl>E', "Expand abbreviation to raw HTML/CSS", self.expand_abbreviation), ('ZenCodingExpandWAction', None, 'E_xpand dynamic abbreviation...', '<Ctrl><Alt>E', "Dynamically expand abbreviation as you type", self.expand_with_abbreviation), ('ZenCodingWrapAction', None, '_Wrap with abbreviation...', '<Ctrl><Shift>E', "Wrap with code expanded from abbreviation", self.wrap_with_abbreviation), ('ZenCodingInwardAction', None, 'Balance tag _inward', '<Ctrl><Alt>I', "Select inner tag's content", self.match_pair_inward), ('ZenCodingOutwardAction', None, 'Balance tag _outward', '<Ctrl><Alt>O', "Select outer tag's content", self.match_pair_outward), ('ZenCodingMergeAction', None, '_Merge lines', '<Ctrl><Alt>M', "Merge all lines of the current selection", self.merge_lines), ('ZenCodingPrevAction', None, '_Previous edit point', '<Alt>Left', "Place the cursor at the previous edit point", self.prev_edit_point), ('ZenCodingNextAction', None, '_Next edit point', '<Alt>Right', "Place the cursor at the next edit point", self.next_edit_point), ('ZenCodingRemoveAction', None, '_Remove tag', '<Ctrl><Alt>R', "Remove a tag", self.remove_tag), ('ZenCodingSplitAction', None, 'Split or _join tag', '<Ctrl><Alt>J', "Toggle between single and double tag", self.split_join_tag), ('ZenCodingCommentAction', None, 'Toggle _comment', '<Ctrl><Alt>C', "Toggle an XML or HTML comment", self.toggle_comment) ] windowdata = dict() window.set_data("ZenCodingPluginDataKey", windowdata) windowdata["action_group"] = gtk.ActionGroup("PlumaZenCodingPluginActions") windowdata["action_group"].add_actions(actions, window) manager = window.get_ui_manager() manager.insert_action_group(windowdata["action_group"], -1) windowdata["ui_id"] = manager.add_ui_from_string(zencoding_ui_str) window.set_data("ZenCodingPluginInfo", windowdata) self.editor = ZenEditor() error = self.editor.get_user_settings_error() if error: md = gtk.MessageDialog(window, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE, "There is an error in user settings:") message = "{0} on line {1} at character {2}\n\nUser settings will not be available." md.set_title("Zen Coding error") md.format_secondary_text(message.format(error['msg'], error['lineno'], error['offset'])) md.run() md.destroy() def deactivate(self, window): windowdata = window.get_data("ZenCodingPluginDataKey") manager = window.get_ui_manager() manager.remove_ui(windowdata["ui_id"]) manager.remove_action_group(windowdata["action_group"]) def update_ui(self, window): view = window.get_active_view() windowdata = window.get_data("ZenCodingPluginDataKey") windowdata["action_group"].set_sensitive(bool(view and view.get_editable())) def expand_abbreviation(self, action, window): self.editor.expand_abbreviation(window) def expand_with_abbreviation(self, action, window): self.editor.expand_with_abbreviation(window) def wrap_with_abbreviation(self, action, window): self.editor.wrap_with_abbreviation(window) def <|fim_middle|>(self, action, window): self.editor.match_pair_inward(window) def match_pair_outward(self, action, window): self.editor.match_pair_outward(window) def merge_lines(self, action, window): self.editor.merge_lines(window) def prev_edit_point(self, action, window): self.editor.prev_edit_point(window) def next_edit_point(self, action, window): self.editor.next_edit_point(window) def remove_tag(self, action, window): self.editor.remove_tag(window) def split_join_tag(self, action, window): self.editor.split_join_tag(window) def toggle_comment(self, action, window): self.editor.toggle_comment(window) <|fim▁end|>
match_pair_inward
<|file_name|>plugin.py<|end_file_name|><|fim▁begin|># @file plugin.py # # Connect Zen Coding to Pluma. # # Adapted to pluma by Joao Manoel ([email protected]) # # Original Author Franck Marcia ([email protected]) # import pluma, gobject, gtk, os from zen_editor import ZenEditor zencoding_ui_str = """ <ui> <menubar name="MenuBar"> <menu name="EditMenu" action="Edit"> <placeholder name="EditOps_5"> <menu action="ZenCodingMenuAction"> <menuitem name="ZenCodingExpand" action="ZenCodingExpandAction"/> <menuitem name="ZenCodingExpandW" action="ZenCodingExpandWAction"/> <menuitem name="ZenCodingWrap" action="ZenCodingWrapAction"/> <separator/> <menuitem name="ZenCodingInward" action="ZenCodingInwardAction"/> <menuitem name="ZenCodingOutward" action="ZenCodingOutwardAction"/> <menuitem name="ZenCodingMerge" action="ZenCodingMergeAction"/> <separator/> <menuitem name="ZenCodingPrev" action="ZenCodingPrevAction"/> <menuitem name="ZenCodingNext" action="ZenCodingNextAction"/> <separator/> <menuitem name="ZenCodingRemove" action="ZenCodingRemoveAction"/> <menuitem name="ZenCodingSplit" action="ZenCodingSplitAction"/> <menuitem name="ZenCodingComment" action="ZenCodingCommentAction"/> </menu> </placeholder> </menu> </menubar> </ui> """ class ZenCodingPlugin(pluma.Plugin): """A Pluma plugin to implement Zen Coding's HTML and CSS shorthand expander.""" def activate(self, window): actions = [ ('ZenCodingMenuAction', None, '_Zen Coding', None, "Zen Coding tools", None), ('ZenCodingExpandAction', None, '_Expand abbreviation', '<Ctrl>E', "Expand abbreviation to raw HTML/CSS", self.expand_abbreviation), ('ZenCodingExpandWAction', None, 'E_xpand dynamic abbreviation...', '<Ctrl><Alt>E', "Dynamically expand abbreviation as you type", self.expand_with_abbreviation), ('ZenCodingWrapAction', None, '_Wrap with abbreviation...', '<Ctrl><Shift>E', "Wrap with code expanded from abbreviation", self.wrap_with_abbreviation), ('ZenCodingInwardAction', None, 'Balance tag _inward', '<Ctrl><Alt>I', "Select inner tag's content", self.match_pair_inward), ('ZenCodingOutwardAction', None, 'Balance tag _outward', '<Ctrl><Alt>O', "Select outer tag's content", self.match_pair_outward), ('ZenCodingMergeAction', None, '_Merge lines', '<Ctrl><Alt>M', "Merge all lines of the current selection", self.merge_lines), ('ZenCodingPrevAction', None, '_Previous edit point', '<Alt>Left', "Place the cursor at the previous edit point", self.prev_edit_point), ('ZenCodingNextAction', None, '_Next edit point', '<Alt>Right', "Place the cursor at the next edit point", self.next_edit_point), ('ZenCodingRemoveAction', None, '_Remove tag', '<Ctrl><Alt>R', "Remove a tag", self.remove_tag), ('ZenCodingSplitAction', None, 'Split or _join tag', '<Ctrl><Alt>J', "Toggle between single and double tag", self.split_join_tag), ('ZenCodingCommentAction', None, 'Toggle _comment', '<Ctrl><Alt>C', "Toggle an XML or HTML comment", self.toggle_comment) ] windowdata = dict() window.set_data("ZenCodingPluginDataKey", windowdata) windowdata["action_group"] = gtk.ActionGroup("PlumaZenCodingPluginActions") windowdata["action_group"].add_actions(actions, window) manager = window.get_ui_manager() manager.insert_action_group(windowdata["action_group"], -1) windowdata["ui_id"] = manager.add_ui_from_string(zencoding_ui_str) window.set_data("ZenCodingPluginInfo", windowdata) self.editor = ZenEditor() error = self.editor.get_user_settings_error() if error: md = gtk.MessageDialog(window, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE, "There is an error in user settings:") message = "{0} on line {1} at character {2}\n\nUser settings will not be available." md.set_title("Zen Coding error") md.format_secondary_text(message.format(error['msg'], error['lineno'], error['offset'])) md.run() md.destroy() def deactivate(self, window): windowdata = window.get_data("ZenCodingPluginDataKey") manager = window.get_ui_manager() manager.remove_ui(windowdata["ui_id"]) manager.remove_action_group(windowdata["action_group"]) def update_ui(self, window): view = window.get_active_view() windowdata = window.get_data("ZenCodingPluginDataKey") windowdata["action_group"].set_sensitive(bool(view and view.get_editable())) def expand_abbreviation(self, action, window): self.editor.expand_abbreviation(window) def expand_with_abbreviation(self, action, window): self.editor.expand_with_abbreviation(window) def wrap_with_abbreviation(self, action, window): self.editor.wrap_with_abbreviation(window) def match_pair_inward(self, action, window): self.editor.match_pair_inward(window) def <|fim_middle|>(self, action, window): self.editor.match_pair_outward(window) def merge_lines(self, action, window): self.editor.merge_lines(window) def prev_edit_point(self, action, window): self.editor.prev_edit_point(window) def next_edit_point(self, action, window): self.editor.next_edit_point(window) def remove_tag(self, action, window): self.editor.remove_tag(window) def split_join_tag(self, action, window): self.editor.split_join_tag(window) def toggle_comment(self, action, window): self.editor.toggle_comment(window) <|fim▁end|>
match_pair_outward
<|file_name|>plugin.py<|end_file_name|><|fim▁begin|># @file plugin.py # # Connect Zen Coding to Pluma. # # Adapted to pluma by Joao Manoel ([email protected]) # # Original Author Franck Marcia ([email protected]) # import pluma, gobject, gtk, os from zen_editor import ZenEditor zencoding_ui_str = """ <ui> <menubar name="MenuBar"> <menu name="EditMenu" action="Edit"> <placeholder name="EditOps_5"> <menu action="ZenCodingMenuAction"> <menuitem name="ZenCodingExpand" action="ZenCodingExpandAction"/> <menuitem name="ZenCodingExpandW" action="ZenCodingExpandWAction"/> <menuitem name="ZenCodingWrap" action="ZenCodingWrapAction"/> <separator/> <menuitem name="ZenCodingInward" action="ZenCodingInwardAction"/> <menuitem name="ZenCodingOutward" action="ZenCodingOutwardAction"/> <menuitem name="ZenCodingMerge" action="ZenCodingMergeAction"/> <separator/> <menuitem name="ZenCodingPrev" action="ZenCodingPrevAction"/> <menuitem name="ZenCodingNext" action="ZenCodingNextAction"/> <separator/> <menuitem name="ZenCodingRemove" action="ZenCodingRemoveAction"/> <menuitem name="ZenCodingSplit" action="ZenCodingSplitAction"/> <menuitem name="ZenCodingComment" action="ZenCodingCommentAction"/> </menu> </placeholder> </menu> </menubar> </ui> """ class ZenCodingPlugin(pluma.Plugin): """A Pluma plugin to implement Zen Coding's HTML and CSS shorthand expander.""" def activate(self, window): actions = [ ('ZenCodingMenuAction', None, '_Zen Coding', None, "Zen Coding tools", None), ('ZenCodingExpandAction', None, '_Expand abbreviation', '<Ctrl>E', "Expand abbreviation to raw HTML/CSS", self.expand_abbreviation), ('ZenCodingExpandWAction', None, 'E_xpand dynamic abbreviation...', '<Ctrl><Alt>E', "Dynamically expand abbreviation as you type", self.expand_with_abbreviation), ('ZenCodingWrapAction', None, '_Wrap with abbreviation...', '<Ctrl><Shift>E', "Wrap with code expanded from abbreviation", self.wrap_with_abbreviation), ('ZenCodingInwardAction', None, 'Balance tag _inward', '<Ctrl><Alt>I', "Select inner tag's content", self.match_pair_inward), ('ZenCodingOutwardAction', None, 'Balance tag _outward', '<Ctrl><Alt>O', "Select outer tag's content", self.match_pair_outward), ('ZenCodingMergeAction', None, '_Merge lines', '<Ctrl><Alt>M', "Merge all lines of the current selection", self.merge_lines), ('ZenCodingPrevAction', None, '_Previous edit point', '<Alt>Left', "Place the cursor at the previous edit point", self.prev_edit_point), ('ZenCodingNextAction', None, '_Next edit point', '<Alt>Right', "Place the cursor at the next edit point", self.next_edit_point), ('ZenCodingRemoveAction', None, '_Remove tag', '<Ctrl><Alt>R', "Remove a tag", self.remove_tag), ('ZenCodingSplitAction', None, 'Split or _join tag', '<Ctrl><Alt>J', "Toggle between single and double tag", self.split_join_tag), ('ZenCodingCommentAction', None, 'Toggle _comment', '<Ctrl><Alt>C', "Toggle an XML or HTML comment", self.toggle_comment) ] windowdata = dict() window.set_data("ZenCodingPluginDataKey", windowdata) windowdata["action_group"] = gtk.ActionGroup("PlumaZenCodingPluginActions") windowdata["action_group"].add_actions(actions, window) manager = window.get_ui_manager() manager.insert_action_group(windowdata["action_group"], -1) windowdata["ui_id"] = manager.add_ui_from_string(zencoding_ui_str) window.set_data("ZenCodingPluginInfo", windowdata) self.editor = ZenEditor() error = self.editor.get_user_settings_error() if error: md = gtk.MessageDialog(window, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE, "There is an error in user settings:") message = "{0} on line {1} at character {2}\n\nUser settings will not be available." md.set_title("Zen Coding error") md.format_secondary_text(message.format(error['msg'], error['lineno'], error['offset'])) md.run() md.destroy() def deactivate(self, window): windowdata = window.get_data("ZenCodingPluginDataKey") manager = window.get_ui_manager() manager.remove_ui(windowdata["ui_id"]) manager.remove_action_group(windowdata["action_group"]) def update_ui(self, window): view = window.get_active_view() windowdata = window.get_data("ZenCodingPluginDataKey") windowdata["action_group"].set_sensitive(bool(view and view.get_editable())) def expand_abbreviation(self, action, window): self.editor.expand_abbreviation(window) def expand_with_abbreviation(self, action, window): self.editor.expand_with_abbreviation(window) def wrap_with_abbreviation(self, action, window): self.editor.wrap_with_abbreviation(window) def match_pair_inward(self, action, window): self.editor.match_pair_inward(window) def match_pair_outward(self, action, window): self.editor.match_pair_outward(window) def <|fim_middle|>(self, action, window): self.editor.merge_lines(window) def prev_edit_point(self, action, window): self.editor.prev_edit_point(window) def next_edit_point(self, action, window): self.editor.next_edit_point(window) def remove_tag(self, action, window): self.editor.remove_tag(window) def split_join_tag(self, action, window): self.editor.split_join_tag(window) def toggle_comment(self, action, window): self.editor.toggle_comment(window) <|fim▁end|>
merge_lines
<|file_name|>plugin.py<|end_file_name|><|fim▁begin|># @file plugin.py # # Connect Zen Coding to Pluma. # # Adapted to pluma by Joao Manoel ([email protected]) # # Original Author Franck Marcia ([email protected]) # import pluma, gobject, gtk, os from zen_editor import ZenEditor zencoding_ui_str = """ <ui> <menubar name="MenuBar"> <menu name="EditMenu" action="Edit"> <placeholder name="EditOps_5"> <menu action="ZenCodingMenuAction"> <menuitem name="ZenCodingExpand" action="ZenCodingExpandAction"/> <menuitem name="ZenCodingExpandW" action="ZenCodingExpandWAction"/> <menuitem name="ZenCodingWrap" action="ZenCodingWrapAction"/> <separator/> <menuitem name="ZenCodingInward" action="ZenCodingInwardAction"/> <menuitem name="ZenCodingOutward" action="ZenCodingOutwardAction"/> <menuitem name="ZenCodingMerge" action="ZenCodingMergeAction"/> <separator/> <menuitem name="ZenCodingPrev" action="ZenCodingPrevAction"/> <menuitem name="ZenCodingNext" action="ZenCodingNextAction"/> <separator/> <menuitem name="ZenCodingRemove" action="ZenCodingRemoveAction"/> <menuitem name="ZenCodingSplit" action="ZenCodingSplitAction"/> <menuitem name="ZenCodingComment" action="ZenCodingCommentAction"/> </menu> </placeholder> </menu> </menubar> </ui> """ class ZenCodingPlugin(pluma.Plugin): """A Pluma plugin to implement Zen Coding's HTML and CSS shorthand expander.""" def activate(self, window): actions = [ ('ZenCodingMenuAction', None, '_Zen Coding', None, "Zen Coding tools", None), ('ZenCodingExpandAction', None, '_Expand abbreviation', '<Ctrl>E', "Expand abbreviation to raw HTML/CSS", self.expand_abbreviation), ('ZenCodingExpandWAction', None, 'E_xpand dynamic abbreviation...', '<Ctrl><Alt>E', "Dynamically expand abbreviation as you type", self.expand_with_abbreviation), ('ZenCodingWrapAction', None, '_Wrap with abbreviation...', '<Ctrl><Shift>E', "Wrap with code expanded from abbreviation", self.wrap_with_abbreviation), ('ZenCodingInwardAction', None, 'Balance tag _inward', '<Ctrl><Alt>I', "Select inner tag's content", self.match_pair_inward), ('ZenCodingOutwardAction', None, 'Balance tag _outward', '<Ctrl><Alt>O', "Select outer tag's content", self.match_pair_outward), ('ZenCodingMergeAction', None, '_Merge lines', '<Ctrl><Alt>M', "Merge all lines of the current selection", self.merge_lines), ('ZenCodingPrevAction', None, '_Previous edit point', '<Alt>Left', "Place the cursor at the previous edit point", self.prev_edit_point), ('ZenCodingNextAction', None, '_Next edit point', '<Alt>Right', "Place the cursor at the next edit point", self.next_edit_point), ('ZenCodingRemoveAction', None, '_Remove tag', '<Ctrl><Alt>R', "Remove a tag", self.remove_tag), ('ZenCodingSplitAction', None, 'Split or _join tag', '<Ctrl><Alt>J', "Toggle between single and double tag", self.split_join_tag), ('ZenCodingCommentAction', None, 'Toggle _comment', '<Ctrl><Alt>C', "Toggle an XML or HTML comment", self.toggle_comment) ] windowdata = dict() window.set_data("ZenCodingPluginDataKey", windowdata) windowdata["action_group"] = gtk.ActionGroup("PlumaZenCodingPluginActions") windowdata["action_group"].add_actions(actions, window) manager = window.get_ui_manager() manager.insert_action_group(windowdata["action_group"], -1) windowdata["ui_id"] = manager.add_ui_from_string(zencoding_ui_str) window.set_data("ZenCodingPluginInfo", windowdata) self.editor = ZenEditor() error = self.editor.get_user_settings_error() if error: md = gtk.MessageDialog(window, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE, "There is an error in user settings:") message = "{0} on line {1} at character {2}\n\nUser settings will not be available." md.set_title("Zen Coding error") md.format_secondary_text(message.format(error['msg'], error['lineno'], error['offset'])) md.run() md.destroy() def deactivate(self, window): windowdata = window.get_data("ZenCodingPluginDataKey") manager = window.get_ui_manager() manager.remove_ui(windowdata["ui_id"]) manager.remove_action_group(windowdata["action_group"]) def update_ui(self, window): view = window.get_active_view() windowdata = window.get_data("ZenCodingPluginDataKey") windowdata["action_group"].set_sensitive(bool(view and view.get_editable())) def expand_abbreviation(self, action, window): self.editor.expand_abbreviation(window) def expand_with_abbreviation(self, action, window): self.editor.expand_with_abbreviation(window) def wrap_with_abbreviation(self, action, window): self.editor.wrap_with_abbreviation(window) def match_pair_inward(self, action, window): self.editor.match_pair_inward(window) def match_pair_outward(self, action, window): self.editor.match_pair_outward(window) def merge_lines(self, action, window): self.editor.merge_lines(window) def <|fim_middle|>(self, action, window): self.editor.prev_edit_point(window) def next_edit_point(self, action, window): self.editor.next_edit_point(window) def remove_tag(self, action, window): self.editor.remove_tag(window) def split_join_tag(self, action, window): self.editor.split_join_tag(window) def toggle_comment(self, action, window): self.editor.toggle_comment(window) <|fim▁end|>
prev_edit_point
<|file_name|>plugin.py<|end_file_name|><|fim▁begin|># @file plugin.py # # Connect Zen Coding to Pluma. # # Adapted to pluma by Joao Manoel ([email protected]) # # Original Author Franck Marcia ([email protected]) # import pluma, gobject, gtk, os from zen_editor import ZenEditor zencoding_ui_str = """ <ui> <menubar name="MenuBar"> <menu name="EditMenu" action="Edit"> <placeholder name="EditOps_5"> <menu action="ZenCodingMenuAction"> <menuitem name="ZenCodingExpand" action="ZenCodingExpandAction"/> <menuitem name="ZenCodingExpandW" action="ZenCodingExpandWAction"/> <menuitem name="ZenCodingWrap" action="ZenCodingWrapAction"/> <separator/> <menuitem name="ZenCodingInward" action="ZenCodingInwardAction"/> <menuitem name="ZenCodingOutward" action="ZenCodingOutwardAction"/> <menuitem name="ZenCodingMerge" action="ZenCodingMergeAction"/> <separator/> <menuitem name="ZenCodingPrev" action="ZenCodingPrevAction"/> <menuitem name="ZenCodingNext" action="ZenCodingNextAction"/> <separator/> <menuitem name="ZenCodingRemove" action="ZenCodingRemoveAction"/> <menuitem name="ZenCodingSplit" action="ZenCodingSplitAction"/> <menuitem name="ZenCodingComment" action="ZenCodingCommentAction"/> </menu> </placeholder> </menu> </menubar> </ui> """ class ZenCodingPlugin(pluma.Plugin): """A Pluma plugin to implement Zen Coding's HTML and CSS shorthand expander.""" def activate(self, window): actions = [ ('ZenCodingMenuAction', None, '_Zen Coding', None, "Zen Coding tools", None), ('ZenCodingExpandAction', None, '_Expand abbreviation', '<Ctrl>E', "Expand abbreviation to raw HTML/CSS", self.expand_abbreviation), ('ZenCodingExpandWAction', None, 'E_xpand dynamic abbreviation...', '<Ctrl><Alt>E', "Dynamically expand abbreviation as you type", self.expand_with_abbreviation), ('ZenCodingWrapAction', None, '_Wrap with abbreviation...', '<Ctrl><Shift>E', "Wrap with code expanded from abbreviation", self.wrap_with_abbreviation), ('ZenCodingInwardAction', None, 'Balance tag _inward', '<Ctrl><Alt>I', "Select inner tag's content", self.match_pair_inward), ('ZenCodingOutwardAction', None, 'Balance tag _outward', '<Ctrl><Alt>O', "Select outer tag's content", self.match_pair_outward), ('ZenCodingMergeAction', None, '_Merge lines', '<Ctrl><Alt>M', "Merge all lines of the current selection", self.merge_lines), ('ZenCodingPrevAction', None, '_Previous edit point', '<Alt>Left', "Place the cursor at the previous edit point", self.prev_edit_point), ('ZenCodingNextAction', None, '_Next edit point', '<Alt>Right', "Place the cursor at the next edit point", self.next_edit_point), ('ZenCodingRemoveAction', None, '_Remove tag', '<Ctrl><Alt>R', "Remove a tag", self.remove_tag), ('ZenCodingSplitAction', None, 'Split or _join tag', '<Ctrl><Alt>J', "Toggle between single and double tag", self.split_join_tag), ('ZenCodingCommentAction', None, 'Toggle _comment', '<Ctrl><Alt>C', "Toggle an XML or HTML comment", self.toggle_comment) ] windowdata = dict() window.set_data("ZenCodingPluginDataKey", windowdata) windowdata["action_group"] = gtk.ActionGroup("PlumaZenCodingPluginActions") windowdata["action_group"].add_actions(actions, window) manager = window.get_ui_manager() manager.insert_action_group(windowdata["action_group"], -1) windowdata["ui_id"] = manager.add_ui_from_string(zencoding_ui_str) window.set_data("ZenCodingPluginInfo", windowdata) self.editor = ZenEditor() error = self.editor.get_user_settings_error() if error: md = gtk.MessageDialog(window, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE, "There is an error in user settings:") message = "{0} on line {1} at character {2}\n\nUser settings will not be available." md.set_title("Zen Coding error") md.format_secondary_text(message.format(error['msg'], error['lineno'], error['offset'])) md.run() md.destroy() def deactivate(self, window): windowdata = window.get_data("ZenCodingPluginDataKey") manager = window.get_ui_manager() manager.remove_ui(windowdata["ui_id"]) manager.remove_action_group(windowdata["action_group"]) def update_ui(self, window): view = window.get_active_view() windowdata = window.get_data("ZenCodingPluginDataKey") windowdata["action_group"].set_sensitive(bool(view and view.get_editable())) def expand_abbreviation(self, action, window): self.editor.expand_abbreviation(window) def expand_with_abbreviation(self, action, window): self.editor.expand_with_abbreviation(window) def wrap_with_abbreviation(self, action, window): self.editor.wrap_with_abbreviation(window) def match_pair_inward(self, action, window): self.editor.match_pair_inward(window) def match_pair_outward(self, action, window): self.editor.match_pair_outward(window) def merge_lines(self, action, window): self.editor.merge_lines(window) def prev_edit_point(self, action, window): self.editor.prev_edit_point(window) def <|fim_middle|>(self, action, window): self.editor.next_edit_point(window) def remove_tag(self, action, window): self.editor.remove_tag(window) def split_join_tag(self, action, window): self.editor.split_join_tag(window) def toggle_comment(self, action, window): self.editor.toggle_comment(window) <|fim▁end|>
next_edit_point
<|file_name|>plugin.py<|end_file_name|><|fim▁begin|># @file plugin.py # # Connect Zen Coding to Pluma. # # Adapted to pluma by Joao Manoel ([email protected]) # # Original Author Franck Marcia ([email protected]) # import pluma, gobject, gtk, os from zen_editor import ZenEditor zencoding_ui_str = """ <ui> <menubar name="MenuBar"> <menu name="EditMenu" action="Edit"> <placeholder name="EditOps_5"> <menu action="ZenCodingMenuAction"> <menuitem name="ZenCodingExpand" action="ZenCodingExpandAction"/> <menuitem name="ZenCodingExpandW" action="ZenCodingExpandWAction"/> <menuitem name="ZenCodingWrap" action="ZenCodingWrapAction"/> <separator/> <menuitem name="ZenCodingInward" action="ZenCodingInwardAction"/> <menuitem name="ZenCodingOutward" action="ZenCodingOutwardAction"/> <menuitem name="ZenCodingMerge" action="ZenCodingMergeAction"/> <separator/> <menuitem name="ZenCodingPrev" action="ZenCodingPrevAction"/> <menuitem name="ZenCodingNext" action="ZenCodingNextAction"/> <separator/> <menuitem name="ZenCodingRemove" action="ZenCodingRemoveAction"/> <menuitem name="ZenCodingSplit" action="ZenCodingSplitAction"/> <menuitem name="ZenCodingComment" action="ZenCodingCommentAction"/> </menu> </placeholder> </menu> </menubar> </ui> """ class ZenCodingPlugin(pluma.Plugin): """A Pluma plugin to implement Zen Coding's HTML and CSS shorthand expander.""" def activate(self, window): actions = [ ('ZenCodingMenuAction', None, '_Zen Coding', None, "Zen Coding tools", None), ('ZenCodingExpandAction', None, '_Expand abbreviation', '<Ctrl>E', "Expand abbreviation to raw HTML/CSS", self.expand_abbreviation), ('ZenCodingExpandWAction', None, 'E_xpand dynamic abbreviation...', '<Ctrl><Alt>E', "Dynamically expand abbreviation as you type", self.expand_with_abbreviation), ('ZenCodingWrapAction', None, '_Wrap with abbreviation...', '<Ctrl><Shift>E', "Wrap with code expanded from abbreviation", self.wrap_with_abbreviation), ('ZenCodingInwardAction', None, 'Balance tag _inward', '<Ctrl><Alt>I', "Select inner tag's content", self.match_pair_inward), ('ZenCodingOutwardAction', None, 'Balance tag _outward', '<Ctrl><Alt>O', "Select outer tag's content", self.match_pair_outward), ('ZenCodingMergeAction', None, '_Merge lines', '<Ctrl><Alt>M', "Merge all lines of the current selection", self.merge_lines), ('ZenCodingPrevAction', None, '_Previous edit point', '<Alt>Left', "Place the cursor at the previous edit point", self.prev_edit_point), ('ZenCodingNextAction', None, '_Next edit point', '<Alt>Right', "Place the cursor at the next edit point", self.next_edit_point), ('ZenCodingRemoveAction', None, '_Remove tag', '<Ctrl><Alt>R', "Remove a tag", self.remove_tag), ('ZenCodingSplitAction', None, 'Split or _join tag', '<Ctrl><Alt>J', "Toggle between single and double tag", self.split_join_tag), ('ZenCodingCommentAction', None, 'Toggle _comment', '<Ctrl><Alt>C', "Toggle an XML or HTML comment", self.toggle_comment) ] windowdata = dict() window.set_data("ZenCodingPluginDataKey", windowdata) windowdata["action_group"] = gtk.ActionGroup("PlumaZenCodingPluginActions") windowdata["action_group"].add_actions(actions, window) manager = window.get_ui_manager() manager.insert_action_group(windowdata["action_group"], -1) windowdata["ui_id"] = manager.add_ui_from_string(zencoding_ui_str) window.set_data("ZenCodingPluginInfo", windowdata) self.editor = ZenEditor() error = self.editor.get_user_settings_error() if error: md = gtk.MessageDialog(window, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE, "There is an error in user settings:") message = "{0} on line {1} at character {2}\n\nUser settings will not be available." md.set_title("Zen Coding error") md.format_secondary_text(message.format(error['msg'], error['lineno'], error['offset'])) md.run() md.destroy() def deactivate(self, window): windowdata = window.get_data("ZenCodingPluginDataKey") manager = window.get_ui_manager() manager.remove_ui(windowdata["ui_id"]) manager.remove_action_group(windowdata["action_group"]) def update_ui(self, window): view = window.get_active_view() windowdata = window.get_data("ZenCodingPluginDataKey") windowdata["action_group"].set_sensitive(bool(view and view.get_editable())) def expand_abbreviation(self, action, window): self.editor.expand_abbreviation(window) def expand_with_abbreviation(self, action, window): self.editor.expand_with_abbreviation(window) def wrap_with_abbreviation(self, action, window): self.editor.wrap_with_abbreviation(window) def match_pair_inward(self, action, window): self.editor.match_pair_inward(window) def match_pair_outward(self, action, window): self.editor.match_pair_outward(window) def merge_lines(self, action, window): self.editor.merge_lines(window) def prev_edit_point(self, action, window): self.editor.prev_edit_point(window) def next_edit_point(self, action, window): self.editor.next_edit_point(window) def <|fim_middle|>(self, action, window): self.editor.remove_tag(window) def split_join_tag(self, action, window): self.editor.split_join_tag(window) def toggle_comment(self, action, window): self.editor.toggle_comment(window) <|fim▁end|>
remove_tag
<|file_name|>plugin.py<|end_file_name|><|fim▁begin|># @file plugin.py # # Connect Zen Coding to Pluma. # # Adapted to pluma by Joao Manoel ([email protected]) # # Original Author Franck Marcia ([email protected]) # import pluma, gobject, gtk, os from zen_editor import ZenEditor zencoding_ui_str = """ <ui> <menubar name="MenuBar"> <menu name="EditMenu" action="Edit"> <placeholder name="EditOps_5"> <menu action="ZenCodingMenuAction"> <menuitem name="ZenCodingExpand" action="ZenCodingExpandAction"/> <menuitem name="ZenCodingExpandW" action="ZenCodingExpandWAction"/> <menuitem name="ZenCodingWrap" action="ZenCodingWrapAction"/> <separator/> <menuitem name="ZenCodingInward" action="ZenCodingInwardAction"/> <menuitem name="ZenCodingOutward" action="ZenCodingOutwardAction"/> <menuitem name="ZenCodingMerge" action="ZenCodingMergeAction"/> <separator/> <menuitem name="ZenCodingPrev" action="ZenCodingPrevAction"/> <menuitem name="ZenCodingNext" action="ZenCodingNextAction"/> <separator/> <menuitem name="ZenCodingRemove" action="ZenCodingRemoveAction"/> <menuitem name="ZenCodingSplit" action="ZenCodingSplitAction"/> <menuitem name="ZenCodingComment" action="ZenCodingCommentAction"/> </menu> </placeholder> </menu> </menubar> </ui> """ class ZenCodingPlugin(pluma.Plugin): """A Pluma plugin to implement Zen Coding's HTML and CSS shorthand expander.""" def activate(self, window): actions = [ ('ZenCodingMenuAction', None, '_Zen Coding', None, "Zen Coding tools", None), ('ZenCodingExpandAction', None, '_Expand abbreviation', '<Ctrl>E', "Expand abbreviation to raw HTML/CSS", self.expand_abbreviation), ('ZenCodingExpandWAction', None, 'E_xpand dynamic abbreviation...', '<Ctrl><Alt>E', "Dynamically expand abbreviation as you type", self.expand_with_abbreviation), ('ZenCodingWrapAction', None, '_Wrap with abbreviation...', '<Ctrl><Shift>E', "Wrap with code expanded from abbreviation", self.wrap_with_abbreviation), ('ZenCodingInwardAction', None, 'Balance tag _inward', '<Ctrl><Alt>I', "Select inner tag's content", self.match_pair_inward), ('ZenCodingOutwardAction', None, 'Balance tag _outward', '<Ctrl><Alt>O', "Select outer tag's content", self.match_pair_outward), ('ZenCodingMergeAction', None, '_Merge lines', '<Ctrl><Alt>M', "Merge all lines of the current selection", self.merge_lines), ('ZenCodingPrevAction', None, '_Previous edit point', '<Alt>Left', "Place the cursor at the previous edit point", self.prev_edit_point), ('ZenCodingNextAction', None, '_Next edit point', '<Alt>Right', "Place the cursor at the next edit point", self.next_edit_point), ('ZenCodingRemoveAction', None, '_Remove tag', '<Ctrl><Alt>R', "Remove a tag", self.remove_tag), ('ZenCodingSplitAction', None, 'Split or _join tag', '<Ctrl><Alt>J', "Toggle between single and double tag", self.split_join_tag), ('ZenCodingCommentAction', None, 'Toggle _comment', '<Ctrl><Alt>C', "Toggle an XML or HTML comment", self.toggle_comment) ] windowdata = dict() window.set_data("ZenCodingPluginDataKey", windowdata) windowdata["action_group"] = gtk.ActionGroup("PlumaZenCodingPluginActions") windowdata["action_group"].add_actions(actions, window) manager = window.get_ui_manager() manager.insert_action_group(windowdata["action_group"], -1) windowdata["ui_id"] = manager.add_ui_from_string(zencoding_ui_str) window.set_data("ZenCodingPluginInfo", windowdata) self.editor = ZenEditor() error = self.editor.get_user_settings_error() if error: md = gtk.MessageDialog(window, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE, "There is an error in user settings:") message = "{0} on line {1} at character {2}\n\nUser settings will not be available." md.set_title("Zen Coding error") md.format_secondary_text(message.format(error['msg'], error['lineno'], error['offset'])) md.run() md.destroy() def deactivate(self, window): windowdata = window.get_data("ZenCodingPluginDataKey") manager = window.get_ui_manager() manager.remove_ui(windowdata["ui_id"]) manager.remove_action_group(windowdata["action_group"]) def update_ui(self, window): view = window.get_active_view() windowdata = window.get_data("ZenCodingPluginDataKey") windowdata["action_group"].set_sensitive(bool(view and view.get_editable())) def expand_abbreviation(self, action, window): self.editor.expand_abbreviation(window) def expand_with_abbreviation(self, action, window): self.editor.expand_with_abbreviation(window) def wrap_with_abbreviation(self, action, window): self.editor.wrap_with_abbreviation(window) def match_pair_inward(self, action, window): self.editor.match_pair_inward(window) def match_pair_outward(self, action, window): self.editor.match_pair_outward(window) def merge_lines(self, action, window): self.editor.merge_lines(window) def prev_edit_point(self, action, window): self.editor.prev_edit_point(window) def next_edit_point(self, action, window): self.editor.next_edit_point(window) def remove_tag(self, action, window): self.editor.remove_tag(window) def <|fim_middle|>(self, action, window): self.editor.split_join_tag(window) def toggle_comment(self, action, window): self.editor.toggle_comment(window) <|fim▁end|>
split_join_tag
<|file_name|>plugin.py<|end_file_name|><|fim▁begin|># @file plugin.py # # Connect Zen Coding to Pluma. # # Adapted to pluma by Joao Manoel ([email protected]) # # Original Author Franck Marcia ([email protected]) # import pluma, gobject, gtk, os from zen_editor import ZenEditor zencoding_ui_str = """ <ui> <menubar name="MenuBar"> <menu name="EditMenu" action="Edit"> <placeholder name="EditOps_5"> <menu action="ZenCodingMenuAction"> <menuitem name="ZenCodingExpand" action="ZenCodingExpandAction"/> <menuitem name="ZenCodingExpandW" action="ZenCodingExpandWAction"/> <menuitem name="ZenCodingWrap" action="ZenCodingWrapAction"/> <separator/> <menuitem name="ZenCodingInward" action="ZenCodingInwardAction"/> <menuitem name="ZenCodingOutward" action="ZenCodingOutwardAction"/> <menuitem name="ZenCodingMerge" action="ZenCodingMergeAction"/> <separator/> <menuitem name="ZenCodingPrev" action="ZenCodingPrevAction"/> <menuitem name="ZenCodingNext" action="ZenCodingNextAction"/> <separator/> <menuitem name="ZenCodingRemove" action="ZenCodingRemoveAction"/> <menuitem name="ZenCodingSplit" action="ZenCodingSplitAction"/> <menuitem name="ZenCodingComment" action="ZenCodingCommentAction"/> </menu> </placeholder> </menu> </menubar> </ui> """ class ZenCodingPlugin(pluma.Plugin): """A Pluma plugin to implement Zen Coding's HTML and CSS shorthand expander.""" def activate(self, window): actions = [ ('ZenCodingMenuAction', None, '_Zen Coding', None, "Zen Coding tools", None), ('ZenCodingExpandAction', None, '_Expand abbreviation', '<Ctrl>E', "Expand abbreviation to raw HTML/CSS", self.expand_abbreviation), ('ZenCodingExpandWAction', None, 'E_xpand dynamic abbreviation...', '<Ctrl><Alt>E', "Dynamically expand abbreviation as you type", self.expand_with_abbreviation), ('ZenCodingWrapAction', None, '_Wrap with abbreviation...', '<Ctrl><Shift>E', "Wrap with code expanded from abbreviation", self.wrap_with_abbreviation), ('ZenCodingInwardAction', None, 'Balance tag _inward', '<Ctrl><Alt>I', "Select inner tag's content", self.match_pair_inward), ('ZenCodingOutwardAction', None, 'Balance tag _outward', '<Ctrl><Alt>O', "Select outer tag's content", self.match_pair_outward), ('ZenCodingMergeAction', None, '_Merge lines', '<Ctrl><Alt>M', "Merge all lines of the current selection", self.merge_lines), ('ZenCodingPrevAction', None, '_Previous edit point', '<Alt>Left', "Place the cursor at the previous edit point", self.prev_edit_point), ('ZenCodingNextAction', None, '_Next edit point', '<Alt>Right', "Place the cursor at the next edit point", self.next_edit_point), ('ZenCodingRemoveAction', None, '_Remove tag', '<Ctrl><Alt>R', "Remove a tag", self.remove_tag), ('ZenCodingSplitAction', None, 'Split or _join tag', '<Ctrl><Alt>J', "Toggle between single and double tag", self.split_join_tag), ('ZenCodingCommentAction', None, 'Toggle _comment', '<Ctrl><Alt>C', "Toggle an XML or HTML comment", self.toggle_comment) ] windowdata = dict() window.set_data("ZenCodingPluginDataKey", windowdata) windowdata["action_group"] = gtk.ActionGroup("PlumaZenCodingPluginActions") windowdata["action_group"].add_actions(actions, window) manager = window.get_ui_manager() manager.insert_action_group(windowdata["action_group"], -1) windowdata["ui_id"] = manager.add_ui_from_string(zencoding_ui_str) window.set_data("ZenCodingPluginInfo", windowdata) self.editor = ZenEditor() error = self.editor.get_user_settings_error() if error: md = gtk.MessageDialog(window, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE, "There is an error in user settings:") message = "{0} on line {1} at character {2}\n\nUser settings will not be available." md.set_title("Zen Coding error") md.format_secondary_text(message.format(error['msg'], error['lineno'], error['offset'])) md.run() md.destroy() def deactivate(self, window): windowdata = window.get_data("ZenCodingPluginDataKey") manager = window.get_ui_manager() manager.remove_ui(windowdata["ui_id"]) manager.remove_action_group(windowdata["action_group"]) def update_ui(self, window): view = window.get_active_view() windowdata = window.get_data("ZenCodingPluginDataKey") windowdata["action_group"].set_sensitive(bool(view and view.get_editable())) def expand_abbreviation(self, action, window): self.editor.expand_abbreviation(window) def expand_with_abbreviation(self, action, window): self.editor.expand_with_abbreviation(window) def wrap_with_abbreviation(self, action, window): self.editor.wrap_with_abbreviation(window) def match_pair_inward(self, action, window): self.editor.match_pair_inward(window) def match_pair_outward(self, action, window): self.editor.match_pair_outward(window) def merge_lines(self, action, window): self.editor.merge_lines(window) def prev_edit_point(self, action, window): self.editor.prev_edit_point(window) def next_edit_point(self, action, window): self.editor.next_edit_point(window) def remove_tag(self, action, window): self.editor.remove_tag(window) def split_join_tag(self, action, window): self.editor.split_join_tag(window) def <|fim_middle|>(self, action, window): self.editor.toggle_comment(window) <|fim▁end|>
toggle_comment
<|file_name|>plugin.py<|end_file_name|><|fim▁begin|># @file plugin.py # # Connect Zen Coding to Pluma. # # Adapted to pluma by Joao Manoel ([email protected]) # # Original Author Franck Marcia ([email protected]) # import pluma, gobject, gtk, os from zen_editor import ZenEditor zencoding_ui_str = """ <ui> <menubar name="MenuBar"> <menu name="EditMenu" action="Edit"> <placeholder name="EditOps_5"> <menu action="ZenCodingMenuAction"> <menuitem name="ZenCodingExpand" action="ZenCodingExpandAction"/> <menuitem name="ZenCodingExpandW" action="ZenCodingExpandWAction"/> <menuitem name="ZenCodingWrap" action="ZenCodingWrapAction"/> <separator/> <menuitem name="ZenCodingInward" action="ZenCodingInwardAction"/> <menuitem name="ZenCodingOutward" action="ZenCodingOutwardAction"/> <menuitem name="ZenCodingMerge" action="ZenCodingMergeAction"/> <separator/> <menuitem name="ZenCodingPrev" action="ZenCodingPrevAction"/> <menuitem name="ZenCodingNext" action="ZenCodingNextAction"/> <separator/> <menuitem name="ZenCodingRemove" action="ZenCodingRemoveAction"/> <menuitem name="ZenCodingSplit" action="ZenCodingSplitAction"/> <menuitem name="ZenCodingComment" action="ZenCodingCommentAction"/> </menu> </placeholder> </menu> </menubar> </ui> """ class ZenCodingPlugin(pluma.Plugin): """A Pluma plugin to implement Zen Coding's HTML and CSS shorthand expander.""" def activate(self, window): actions = [ ('ZenCodingMenuAction', None, '_Zen Coding', None, "Zen Coding tools", None), ('ZenCodingExpandAction', None, '_Expand abbreviation', '<Ctrl>E', "Expand abbreviation to raw HTML/CSS", self.expand_abbreviation),<|fim▁hole|> ('ZenCodingWrapAction', None, '_Wrap with abbreviation...', '<Ctrl><Shift>E', "Wrap with code expanded from abbreviation", self.wrap_with_abbreviation), ('ZenCodingInwardAction', None, 'Balance tag _inward', '<Ctrl><Alt>I', "Select inner tag's content", self.match_pair_inward), ('ZenCodingOutwardAction', None, 'Balance tag _outward', '<Ctrl><Alt>O', "Select outer tag's content", self.match_pair_outward), ('ZenCodingMergeAction', None, '_Merge lines', '<Ctrl><Alt>M', "Merge all lines of the current selection", self.merge_lines), ('ZenCodingPrevAction', None, '_Previous edit point', '<Alt>Left', "Place the cursor at the previous edit point", self.prev_edit_point), ('ZenCodingNextAction', None, '_Next edit point', '<Alt>Right', "Place the cursor at the next edit point", self.next_edit_point), ('ZenCodingRemoveAction', None, '_Remove tag', '<Ctrl><Alt>R', "Remove a tag", self.remove_tag), ('ZenCodingSplitAction', None, 'Split or _join tag', '<Ctrl><Alt>J', "Toggle between single and double tag", self.split_join_tag), ('ZenCodingCommentAction', None, 'Toggle _comment', '<Ctrl><Alt>C', "Toggle an XML or HTML comment", self.toggle_comment) ] windowdata = dict() window.set_data("ZenCodingPluginDataKey", windowdata) windowdata["action_group"] = gtk.ActionGroup("PlumaZenCodingPluginActions") windowdata["action_group"].add_actions(actions, window) manager = window.get_ui_manager() manager.insert_action_group(windowdata["action_group"], -1) windowdata["ui_id"] = manager.add_ui_from_string(zencoding_ui_str) window.set_data("ZenCodingPluginInfo", windowdata) self.editor = ZenEditor() error = self.editor.get_user_settings_error() if error: md = gtk.MessageDialog(window, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE, "There is an error in user settings:") message = "{0} on line {1} at character {2}\n\nUser settings will not be available." md.set_title("Zen Coding error") md.format_secondary_text(message.format(error['msg'], error['lineno'], error['offset'])) md.run() md.destroy() def deactivate(self, window): windowdata = window.get_data("ZenCodingPluginDataKey") manager = window.get_ui_manager() manager.remove_ui(windowdata["ui_id"]) manager.remove_action_group(windowdata["action_group"]) def update_ui(self, window): view = window.get_active_view() windowdata = window.get_data("ZenCodingPluginDataKey") windowdata["action_group"].set_sensitive(bool(view and view.get_editable())) def expand_abbreviation(self, action, window): self.editor.expand_abbreviation(window) def expand_with_abbreviation(self, action, window): self.editor.expand_with_abbreviation(window) def wrap_with_abbreviation(self, action, window): self.editor.wrap_with_abbreviation(window) def match_pair_inward(self, action, window): self.editor.match_pair_inward(window) def match_pair_outward(self, action, window): self.editor.match_pair_outward(window) def merge_lines(self, action, window): self.editor.merge_lines(window) def prev_edit_point(self, action, window): self.editor.prev_edit_point(window) def next_edit_point(self, action, window): self.editor.next_edit_point(window) def remove_tag(self, action, window): self.editor.remove_tag(window) def split_join_tag(self, action, window): self.editor.split_join_tag(window) def toggle_comment(self, action, window): self.editor.toggle_comment(window)<|fim▁end|>
('ZenCodingExpandWAction', None, 'E_xpand dynamic abbreviation...', '<Ctrl><Alt>E', "Dynamically expand abbreviation as you type", self.expand_with_abbreviation),
<|file_name|>plugin.py<|end_file_name|><|fim▁begin|># @file plugin.py # # Connect Zen Coding to Pluma. # # Adapted to pluma by Joao Manoel ([email protected]) # # Original Author Franck Marcia ([email protected]) # import pluma, gobject, gtk, os from zen_editor import ZenEditor zencoding_ui_str = """ <ui> <menubar name="MenuBar"> <menu name="EditMenu" action="Edit"> <placeholder name="EditOps_5"> <menu action="ZenCodingMenuAction"> <menuitem name="ZenCodingExpand" action="ZenCodingExpandAction"/> <menuitem name="ZenCodingExpandW" action="ZenCodingExpandWAction"/> <menuitem name="ZenCodingWrap" action="ZenCodingWrapAction"/> <separator/> <menuitem name="ZenCodingInward" action="ZenCodingInwardAction"/> <menuitem name="ZenCodingOutward" action="ZenCodingOutwardAction"/> <menuitem name="ZenCodingMerge" action="ZenCodingMergeAction"/> <separator/> <menuitem name="ZenCodingPrev" action="ZenCodingPrevAction"/> <menuitem name="ZenCodingNext" action="ZenCodingNextAction"/> <separator/> <menuitem name="ZenCodingRemove" action="ZenCodingRemoveAction"/> <menuitem name="ZenCodingSplit" action="ZenCodingSplitAction"/> <menuitem name="ZenCodingComment" action="ZenCodingCommentAction"/> </menu> </placeholder> </menu> </menubar> </ui> """ class ZenCodingPlugin(pluma.Plugin): """A Pluma plugin to implement Zen Coding's HTML and CSS shorthand expander.""" def activate(self, window): actions = [ ('ZenCodingMenuAction', None, '_Zen Coding', None, "Zen Coding tools", None), ('ZenCodingExpandAction', None, '_Expand abbreviation', '<Ctrl>E', "Expand abbreviation to raw HTML/CSS", self.expand_abbreviation), ('ZenCodingExpandWAction', None, 'E_xpand dynamic abbreviation...', '<Ctrl><Alt>E', "Dynamically expand abbreviation as you type", self.expand_with_abbreviation), ('ZenCodingWrapAction', None, '_Wrap with abbreviation...', '<Ctrl><Shift>E', "Wrap with code expanded from abbreviation", self.wrap_with_abbreviation), ('ZenCodingInwardAction', None, 'Balance tag _inward', '<Ctrl><Alt>I', "Select inner tag's content", self.match_pair_inward), ('ZenCodingOutwardAction', None, 'Balance tag _outward', '<Ctrl><Alt>O', "Select outer tag's content", self.match_pair_outward), ('ZenCodingMergeAction', None, '_Merge lines', '<Ctrl><Alt>M', "Merge all lines of the current selection", self.merge_lines), ('ZenCodingPrevAction', None, '_Previous edit point', '<Alt>Left', "Place the cursor at the previous edit point", self.prev_edit_point), ('ZenCodingNextAction', None, '_Next edit point', '<Alt>Right', "Place the cursor at the next edit point", self.next_edit_point), ('ZenCodingRemoveAction', None, '_Remove tag', '<Ctrl><Alt>R', "Remove a tag", self.remove_tag), ('ZenCodingSplitAction', None, 'Split or _join tag', '<Ctrl><Alt>J', "Toggle between single and double tag", self.split_join_tag), ('ZenCodingCommentAction', None, 'Toggle _comment', '<Ctrl><Alt>C', "Toggle an XML or HTML comment", self.toggle_comment) ] windowdata = dict() window.set_data("ZenCodingPluginDataKey", windowdata) windowdata["action_group"] = gtk.ActionGroup("PlumaZenCodingPluginActions") windowdata["action_group"].add_actions(actions, window) manager = window.get_ui_manager() manager.insert_action_group(windowdata["action_group"], -1) windowdata["ui_id"] = manager.add_ui_from_string(zencoding_ui_str) window.set_data("ZenCodingPluginInfo", windowdata) self.editor = ZenEditor() error = self.editor.get_user_settings_error() if error: <|fim_middle|> def deactivate(self, window): windowdata = window.get_data("ZenCodingPluginDataKey") manager = window.get_ui_manager() manager.remove_ui(windowdata["ui_id"]) manager.remove_action_group(windowdata["action_group"]) def update_ui(self, window): view = window.get_active_view() windowdata = window.get_data("ZenCodingPluginDataKey") windowdata["action_group"].set_sensitive(bool(view and view.get_editable())) def expand_abbreviation(self, action, window): self.editor.expand_abbreviation(window) def expand_with_abbreviation(self, action, window): self.editor.expand_with_abbreviation(window) def wrap_with_abbreviation(self, action, window): self.editor.wrap_with_abbreviation(window) def match_pair_inward(self, action, window): self.editor.match_pair_inward(window) def match_pair_outward(self, action, window): self.editor.match_pair_outward(window) def merge_lines(self, action, window): self.editor.merge_lines(window) def prev_edit_point(self, action, window): self.editor.prev_edit_point(window) def next_edit_point(self, action, window): self.editor.next_edit_point(window) def remove_tag(self, action, window): self.editor.remove_tag(window) def split_join_tag(self, action, window): self.editor.split_join_tag(window) def toggle_comment(self, action, window): self.editor.toggle_comment(window) <|fim▁end|>
md = gtk.MessageDialog(window, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE, "There is an error in user settings:") message = "{0} on line {1} at character {2}\n\nUser settings will not be available." md.set_title("Zen Coding error") md.format_secondary_text(message.format(error['msg'], error['lineno'], error['offset'])) md.run() md.destroy()
<|file_name|>logHist.py<|end_file_name|><|fim▁begin|>import matplotlib.pyplot as plt import numpy as np def logHist(X, N=30,fig=None, noclear=False, pdf=False, **kywds): ''' Plot logarithmic histogram or probability density function from sampled data. Args: X (numpy.ndarray): 1-D array of sampled values N (Optional[int]): Number of bins (default 30) fig (Optional[int]): Figure number (default None) noclear (Optioanl[bool]): Clear figure (default False) pdf (Optional[bool]): If True normalize by bin width (default False) and display as curve instead of bar chart. Note: results are always normalized by number of samples **kywds: Arbitrary keyword arguments passed to matplotlib.pyplot.bar (or matplotlib.pyplot.semilogx if pdf is True) Returns: x (ndarray): abscissa values of frequencies n (ndarray): (normalized) frequency values ''' x = np.logspace(np.log10(np.min(X)),np.log10(np.max(X)),N+1) n,x = np.histogram(X,bins=x) n = n/float(X.size) plt.figure(fig) if not noclear: plt.clf() if pdf: n /= np.diff(x) x = x[:-1]+np.diff(x)/2 plt.semilogx(x,n,**kywds) else: plt.bar(x[:len(x)-1],n,width=np.diff(x),**kywds) a = plt.gca() a.set_xlim(10.**np.floor(np.log10(np.min(X))),10.**np.ceil(np.log10(np.max(X)))) a.set_xscale('log') plt.axis() <|fim▁hole|><|fim▁end|>
return x,n
<|file_name|>logHist.py<|end_file_name|><|fim▁begin|>import matplotlib.pyplot as plt import numpy as np def logHist(X, N=30,fig=None, noclear=False, pdf=False, **kywds): <|fim_middle|> <|fim▁end|>
''' Plot logarithmic histogram or probability density function from sampled data. Args: X (numpy.ndarray): 1-D array of sampled values N (Optional[int]): Number of bins (default 30) fig (Optional[int]): Figure number (default None) noclear (Optioanl[bool]): Clear figure (default False) pdf (Optional[bool]): If True normalize by bin width (default False) and display as curve instead of bar chart. Note: results are always normalized by number of samples **kywds: Arbitrary keyword arguments passed to matplotlib.pyplot.bar (or matplotlib.pyplot.semilogx if pdf is True) Returns: x (ndarray): abscissa values of frequencies n (ndarray): (normalized) frequency values ''' x = np.logspace(np.log10(np.min(X)),np.log10(np.max(X)),N+1) n,x = np.histogram(X,bins=x) n = n/float(X.size) plt.figure(fig) if not noclear: plt.clf() if pdf: n /= np.diff(x) x = x[:-1]+np.diff(x)/2 plt.semilogx(x,n,**kywds) else: plt.bar(x[:len(x)-1],n,width=np.diff(x),**kywds) a = plt.gca() a.set_xlim(10.**np.floor(np.log10(np.min(X))),10.**np.ceil(np.log10(np.max(X)))) a.set_xscale('log') plt.axis() return x,n
<|file_name|>logHist.py<|end_file_name|><|fim▁begin|>import matplotlib.pyplot as plt import numpy as np def logHist(X, N=30,fig=None, noclear=False, pdf=False, **kywds): ''' Plot logarithmic histogram or probability density function from sampled data. Args: X (numpy.ndarray): 1-D array of sampled values N (Optional[int]): Number of bins (default 30) fig (Optional[int]): Figure number (default None) noclear (Optioanl[bool]): Clear figure (default False) pdf (Optional[bool]): If True normalize by bin width (default False) and display as curve instead of bar chart. Note: results are always normalized by number of samples **kywds: Arbitrary keyword arguments passed to matplotlib.pyplot.bar (or matplotlib.pyplot.semilogx if pdf is True) Returns: x (ndarray): abscissa values of frequencies n (ndarray): (normalized) frequency values ''' x = np.logspace(np.log10(np.min(X)),np.log10(np.max(X)),N+1) n,x = np.histogram(X,bins=x) n = n/float(X.size) plt.figure(fig) if not noclear: <|fim_middle|> if pdf: n /= np.diff(x) x = x[:-1]+np.diff(x)/2 plt.semilogx(x,n,**kywds) else: plt.bar(x[:len(x)-1],n,width=np.diff(x),**kywds) a = plt.gca() a.set_xlim(10.**np.floor(np.log10(np.min(X))),10.**np.ceil(np.log10(np.max(X)))) a.set_xscale('log') plt.axis() return x,n <|fim▁end|>
plt.clf()
<|file_name|>logHist.py<|end_file_name|><|fim▁begin|>import matplotlib.pyplot as plt import numpy as np def logHist(X, N=30,fig=None, noclear=False, pdf=False, **kywds): ''' Plot logarithmic histogram or probability density function from sampled data. Args: X (numpy.ndarray): 1-D array of sampled values N (Optional[int]): Number of bins (default 30) fig (Optional[int]): Figure number (default None) noclear (Optioanl[bool]): Clear figure (default False) pdf (Optional[bool]): If True normalize by bin width (default False) and display as curve instead of bar chart. Note: results are always normalized by number of samples **kywds: Arbitrary keyword arguments passed to matplotlib.pyplot.bar (or matplotlib.pyplot.semilogx if pdf is True) Returns: x (ndarray): abscissa values of frequencies n (ndarray): (normalized) frequency values ''' x = np.logspace(np.log10(np.min(X)),np.log10(np.max(X)),N+1) n,x = np.histogram(X,bins=x) n = n/float(X.size) plt.figure(fig) if not noclear: plt.clf() if pdf: <|fim_middle|> else: plt.bar(x[:len(x)-1],n,width=np.diff(x),**kywds) a = plt.gca() a.set_xlim(10.**np.floor(np.log10(np.min(X))),10.**np.ceil(np.log10(np.max(X)))) a.set_xscale('log') plt.axis() return x,n <|fim▁end|>
n /= np.diff(x) x = x[:-1]+np.diff(x)/2 plt.semilogx(x,n,**kywds)
<|file_name|>logHist.py<|end_file_name|><|fim▁begin|>import matplotlib.pyplot as plt import numpy as np def logHist(X, N=30,fig=None, noclear=False, pdf=False, **kywds): ''' Plot logarithmic histogram or probability density function from sampled data. Args: X (numpy.ndarray): 1-D array of sampled values N (Optional[int]): Number of bins (default 30) fig (Optional[int]): Figure number (default None) noclear (Optioanl[bool]): Clear figure (default False) pdf (Optional[bool]): If True normalize by bin width (default False) and display as curve instead of bar chart. Note: results are always normalized by number of samples **kywds: Arbitrary keyword arguments passed to matplotlib.pyplot.bar (or matplotlib.pyplot.semilogx if pdf is True) Returns: x (ndarray): abscissa values of frequencies n (ndarray): (normalized) frequency values ''' x = np.logspace(np.log10(np.min(X)),np.log10(np.max(X)),N+1) n,x = np.histogram(X,bins=x) n = n/float(X.size) plt.figure(fig) if not noclear: plt.clf() if pdf: n /= np.diff(x) x = x[:-1]+np.diff(x)/2 plt.semilogx(x,n,**kywds) else: <|fim_middle|> a = plt.gca() a.set_xlim(10.**np.floor(np.log10(np.min(X))),10.**np.ceil(np.log10(np.max(X)))) a.set_xscale('log') plt.axis() return x,n <|fim▁end|>
plt.bar(x[:len(x)-1],n,width=np.diff(x),**kywds)
<|file_name|>logHist.py<|end_file_name|><|fim▁begin|>import matplotlib.pyplot as plt import numpy as np def <|fim_middle|>(X, N=30,fig=None, noclear=False, pdf=False, **kywds): ''' Plot logarithmic histogram or probability density function from sampled data. Args: X (numpy.ndarray): 1-D array of sampled values N (Optional[int]): Number of bins (default 30) fig (Optional[int]): Figure number (default None) noclear (Optioanl[bool]): Clear figure (default False) pdf (Optional[bool]): If True normalize by bin width (default False) and display as curve instead of bar chart. Note: results are always normalized by number of samples **kywds: Arbitrary keyword arguments passed to matplotlib.pyplot.bar (or matplotlib.pyplot.semilogx if pdf is True) Returns: x (ndarray): abscissa values of frequencies n (ndarray): (normalized) frequency values ''' x = np.logspace(np.log10(np.min(X)),np.log10(np.max(X)),N+1) n,x = np.histogram(X,bins=x) n = n/float(X.size) plt.figure(fig) if not noclear: plt.clf() if pdf: n /= np.diff(x) x = x[:-1]+np.diff(x)/2 plt.semilogx(x,n,**kywds) else: plt.bar(x[:len(x)-1],n,width=np.diff(x),**kywds) a = plt.gca() a.set_xlim(10.**np.floor(np.log10(np.min(X))),10.**np.ceil(np.log10(np.max(X)))) a.set_xscale('log') plt.axis() return x,n <|fim▁end|>
logHist
<|file_name|>dialogue.py<|end_file_name|><|fim▁begin|>import numpy as np from numpy import cumsum, sum, searchsorted from numpy.random import rand import math import utils import core.sentence as sentence import core.markovchain as mc import logging logger = logging.getLogger(__name__) # Dialogue making class. Need to review where to return a string, where to return a list of tokens, etc. # setters: list of speakers, pronouns, priors etc. # random transitions # Internal: build list of structures: # e.g.{:speaker_name "Alice", :speaker_pronoun "she", :speaker_str "she", :speech_verb "said", :position "end"} # Then end with fn that maps that out to a suitable string # e.g. "<SPEECH>, she said." # External bit then replaces <SPEECH> with a markov-chain-generated sentence (or several). class dialogue_maker(object): """Class to handle creating dialogue based on a list of speakers and a sentence generator.""" def __init__(self, names, pronouns, mc): self.speakers = [{"name": n, "pronoun": p} for n, p in list(zip(names, pronouns))] self._transitions = self.make_transition_probs() self._speech_acts = ["said", "whispered", "shouted", "cried"] self._acts_transitions = [25, 2, 2, 2] self.mc = mc # self.seeds = seeds self.target_len = np.random.randint(5, 50, size=len(names)) # rough words per sentence<|fim▁hole|> transitions = np.random.randint(5, size=(n, n)) + 1 transitions += transitions.transpose() for i in range(0, math.floor(n / 2)): s1 = np.random.randint(n) s2 = np.random.randint(n) transitions[s1][s2] += 10 transitions[s2][s1] += 8 return(transitions) def after(self, speaker_id): """Pick next person to speak""" row = self._transitions[speaker_id] sucessor = searchsorted(cumsum(row), rand() * sum(row)) return sucessor def speaker_sequence(self, speaker_id, n): """Random walk through transitions matrix to produce a sequence of speaker ids""" seq = [] for i in range(n): seq.append(speaker_id) speaker_id = self.after(speaker_id) return seq def speech_sequence(self, n): speech_acts_seq = [] next_speech_id = 0 for i in range(n): next_speech_id = searchsorted(cumsum(self._acts_transitions), rand() * sum(self._acts_transitions)) speech_acts_seq.append(self._speech_acts[next_speech_id]) return speech_acts_seq def seq_to_names(self, sequence): return([self.speakers[id] for id in sequence]) def make_speech_bits(self, seeds): n = len(seeds) speaker_id = self.speaker_sequence(0, n) speech_acts_seq = self.speech_sequence(n) bits = [] ss = sentence.SentenceMaker(self.mc) for i in range(n): sent_toks = ss.generate_sentence_tokens([seeds[i]], self.target_len[speaker_id[i]]) sent_toks = ss.polish_sentence(sent_toks) bits.append({'speaker_name': self.speakers[speaker_id[i]]["name"], 'speech_act': speech_acts_seq[speaker_id[i]], 'seq_id': speaker_id[i], 'speech': sent_toks, 'paragraph': True}) return(bits) def simplify(self, seq_map): "Take a sequence of speech parts and make more natural by removing name reptition etc." for i in range(0, len(seq_map)): seq_map[i]['speaker_str'] = seq_map[i]['speaker_name'] # default # Same speaker contiues: if i > 0 and seq_map[i]['seq_id'] == seq_map[i - 1]['seq_id']: seq_map[i]['speaker_str'] = "" seq_map[i]['speech_act'] = "" seq_map[i]['paragraph'] = False else: if i > 1 and seq_map[i]['seq_id'] == seq_map[i - 2]['seq_id'] \ and seq_map[i]['seq_id'] != seq_map[i - 1]['seq_id']: seq_map[i]['speaker_str'] = "" seq_map[i]['speech_act'] = "" seq_map[i]['paragraph'] = True return seq_map def report_seq(self, seq_map): """Convert sequence of speeches to a tokens.""" sents = [] for i in range(0, len(seq_map)): if seq_map[i]['paragraph']: # text += "\n " quote_start = '"' else: quote_start = "" if i > len(seq_map) - 2 or seq_map[i + 1]['paragraph']: quote_end = '"' else: quote_end = " " if len(seq_map[i]['speech_act']) > 0: speech_act = seq_map[i]['speech_act'] + "," else: speech_act = seq_map[i]['speech_act'] tokens = [utils.START_TOKEN] tokens.append(seq_map[i]['speaker_str']) tokens.append(speech_act) tokens.append(quote_start) tokens.extend(seq_map[i]['speech'][1:-1]) tokens.append(quote_end) tokens.append(utils.END_TOKEN) sents.append(tokens) return sents def make_dialogue(self, seeds): """Returns a list of sentences, each being a list of tokens.""" acts = self.make_speech_bits(seeds) seq_map = self.simplify(acts) sents = self.report_seq(seq_map) return(sents) def dev(): import knowledge.names as names mcW = mc.MarkovChain() nm = names.NameMaker() speakers = [nm.random_person() for i in range(1, 4)] dm = dialogue_maker([n['name'] for n in speakers], [n['pronoun'] for n in speakers], mcW) dlg = dm.make_dialogue(["dog", "run", "spot"]) print(dlg)<|fim▁end|>
def make_transition_probs(self): """Make transition matrix between speakers, with random symmetric biases added in""" n = len(self.speakers) # TODO why this line ???
<|file_name|>dialogue.py<|end_file_name|><|fim▁begin|>import numpy as np from numpy import cumsum, sum, searchsorted from numpy.random import rand import math import utils import core.sentence as sentence import core.markovchain as mc import logging logger = logging.getLogger(__name__) # Dialogue making class. Need to review where to return a string, where to return a list of tokens, etc. # setters: list of speakers, pronouns, priors etc. # random transitions # Internal: build list of structures: # e.g.{:speaker_name "Alice", :speaker_pronoun "she", :speaker_str "she", :speech_verb "said", :position "end"} # Then end with fn that maps that out to a suitable string # e.g. "<SPEECH>, she said." # External bit then replaces <SPEECH> with a markov-chain-generated sentence (or several). class dialogue_maker(object): <|fim_middle|> def dev(): import knowledge.names as names mcW = mc.MarkovChain() nm = names.NameMaker() speakers = [nm.random_person() for i in range(1, 4)] dm = dialogue_maker([n['name'] for n in speakers], [n['pronoun'] for n in speakers], mcW) dlg = dm.make_dialogue(["dog", "run", "spot"]) print(dlg) <|fim▁end|>
"""Class to handle creating dialogue based on a list of speakers and a sentence generator.""" def __init__(self, names, pronouns, mc): self.speakers = [{"name": n, "pronoun": p} for n, p in list(zip(names, pronouns))] self._transitions = self.make_transition_probs() self._speech_acts = ["said", "whispered", "shouted", "cried"] self._acts_transitions = [25, 2, 2, 2] self.mc = mc # self.seeds = seeds self.target_len = np.random.randint(5, 50, size=len(names)) # rough words per sentence def make_transition_probs(self): """Make transition matrix between speakers, with random symmetric biases added in""" n = len(self.speakers) # TODO why this line ??? transitions = np.random.randint(5, size=(n, n)) + 1 transitions += transitions.transpose() for i in range(0, math.floor(n / 2)): s1 = np.random.randint(n) s2 = np.random.randint(n) transitions[s1][s2] += 10 transitions[s2][s1] += 8 return(transitions) def after(self, speaker_id): """Pick next person to speak""" row = self._transitions[speaker_id] sucessor = searchsorted(cumsum(row), rand() * sum(row)) return sucessor def speaker_sequence(self, speaker_id, n): """Random walk through transitions matrix to produce a sequence of speaker ids""" seq = [] for i in range(n): seq.append(speaker_id) speaker_id = self.after(speaker_id) return seq def speech_sequence(self, n): speech_acts_seq = [] next_speech_id = 0 for i in range(n): next_speech_id = searchsorted(cumsum(self._acts_transitions), rand() * sum(self._acts_transitions)) speech_acts_seq.append(self._speech_acts[next_speech_id]) return speech_acts_seq def seq_to_names(self, sequence): return([self.speakers[id] for id in sequence]) def make_speech_bits(self, seeds): n = len(seeds) speaker_id = self.speaker_sequence(0, n) speech_acts_seq = self.speech_sequence(n) bits = [] ss = sentence.SentenceMaker(self.mc) for i in range(n): sent_toks = ss.generate_sentence_tokens([seeds[i]], self.target_len[speaker_id[i]]) sent_toks = ss.polish_sentence(sent_toks) bits.append({'speaker_name': self.speakers[speaker_id[i]]["name"], 'speech_act': speech_acts_seq[speaker_id[i]], 'seq_id': speaker_id[i], 'speech': sent_toks, 'paragraph': True}) return(bits) def simplify(self, seq_map): "Take a sequence of speech parts and make more natural by removing name reptition etc." for i in range(0, len(seq_map)): seq_map[i]['speaker_str'] = seq_map[i]['speaker_name'] # default # Same speaker contiues: if i > 0 and seq_map[i]['seq_id'] == seq_map[i - 1]['seq_id']: seq_map[i]['speaker_str'] = "" seq_map[i]['speech_act'] = "" seq_map[i]['paragraph'] = False else: if i > 1 and seq_map[i]['seq_id'] == seq_map[i - 2]['seq_id'] \ and seq_map[i]['seq_id'] != seq_map[i - 1]['seq_id']: seq_map[i]['speaker_str'] = "" seq_map[i]['speech_act'] = "" seq_map[i]['paragraph'] = True return seq_map def report_seq(self, seq_map): """Convert sequence of speeches to a tokens.""" sents = [] for i in range(0, len(seq_map)): if seq_map[i]['paragraph']: # text += "\n " quote_start = '"' else: quote_start = "" if i > len(seq_map) - 2 or seq_map[i + 1]['paragraph']: quote_end = '"' else: quote_end = " " if len(seq_map[i]['speech_act']) > 0: speech_act = seq_map[i]['speech_act'] + "," else: speech_act = seq_map[i]['speech_act'] tokens = [utils.START_TOKEN] tokens.append(seq_map[i]['speaker_str']) tokens.append(speech_act) tokens.append(quote_start) tokens.extend(seq_map[i]['speech'][1:-1]) tokens.append(quote_end) tokens.append(utils.END_TOKEN) sents.append(tokens) return sents def make_dialogue(self, seeds): """Returns a list of sentences, each being a list of tokens.""" acts = self.make_speech_bits(seeds) seq_map = self.simplify(acts) sents = self.report_seq(seq_map) return(sents)
<|file_name|>dialogue.py<|end_file_name|><|fim▁begin|>import numpy as np from numpy import cumsum, sum, searchsorted from numpy.random import rand import math import utils import core.sentence as sentence import core.markovchain as mc import logging logger = logging.getLogger(__name__) # Dialogue making class. Need to review where to return a string, where to return a list of tokens, etc. # setters: list of speakers, pronouns, priors etc. # random transitions # Internal: build list of structures: # e.g.{:speaker_name "Alice", :speaker_pronoun "she", :speaker_str "she", :speech_verb "said", :position "end"} # Then end with fn that maps that out to a suitable string # e.g. "<SPEECH>, she said." # External bit then replaces <SPEECH> with a markov-chain-generated sentence (or several). class dialogue_maker(object): """Class to handle creating dialogue based on a list of speakers and a sentence generator.""" def __init__(self, names, pronouns, mc): <|fim_middle|> def make_transition_probs(self): """Make transition matrix between speakers, with random symmetric biases added in""" n = len(self.speakers) # TODO why this line ??? transitions = np.random.randint(5, size=(n, n)) + 1 transitions += transitions.transpose() for i in range(0, math.floor(n / 2)): s1 = np.random.randint(n) s2 = np.random.randint(n) transitions[s1][s2] += 10 transitions[s2][s1] += 8 return(transitions) def after(self, speaker_id): """Pick next person to speak""" row = self._transitions[speaker_id] sucessor = searchsorted(cumsum(row), rand() * sum(row)) return sucessor def speaker_sequence(self, speaker_id, n): """Random walk through transitions matrix to produce a sequence of speaker ids""" seq = [] for i in range(n): seq.append(speaker_id) speaker_id = self.after(speaker_id) return seq def speech_sequence(self, n): speech_acts_seq = [] next_speech_id = 0 for i in range(n): next_speech_id = searchsorted(cumsum(self._acts_transitions), rand() * sum(self._acts_transitions)) speech_acts_seq.append(self._speech_acts[next_speech_id]) return speech_acts_seq def seq_to_names(self, sequence): return([self.speakers[id] for id in sequence]) def make_speech_bits(self, seeds): n = len(seeds) speaker_id = self.speaker_sequence(0, n) speech_acts_seq = self.speech_sequence(n) bits = [] ss = sentence.SentenceMaker(self.mc) for i in range(n): sent_toks = ss.generate_sentence_tokens([seeds[i]], self.target_len[speaker_id[i]]) sent_toks = ss.polish_sentence(sent_toks) bits.append({'speaker_name': self.speakers[speaker_id[i]]["name"], 'speech_act': speech_acts_seq[speaker_id[i]], 'seq_id': speaker_id[i], 'speech': sent_toks, 'paragraph': True}) return(bits) def simplify(self, seq_map): "Take a sequence of speech parts and make more natural by removing name reptition etc." for i in range(0, len(seq_map)): seq_map[i]['speaker_str'] = seq_map[i]['speaker_name'] # default # Same speaker contiues: if i > 0 and seq_map[i]['seq_id'] == seq_map[i - 1]['seq_id']: seq_map[i]['speaker_str'] = "" seq_map[i]['speech_act'] = "" seq_map[i]['paragraph'] = False else: if i > 1 and seq_map[i]['seq_id'] == seq_map[i - 2]['seq_id'] \ and seq_map[i]['seq_id'] != seq_map[i - 1]['seq_id']: seq_map[i]['speaker_str'] = "" seq_map[i]['speech_act'] = "" seq_map[i]['paragraph'] = True return seq_map def report_seq(self, seq_map): """Convert sequence of speeches to a tokens.""" sents = [] for i in range(0, len(seq_map)): if seq_map[i]['paragraph']: # text += "\n " quote_start = '"' else: quote_start = "" if i > len(seq_map) - 2 or seq_map[i + 1]['paragraph']: quote_end = '"' else: quote_end = " " if len(seq_map[i]['speech_act']) > 0: speech_act = seq_map[i]['speech_act'] + "," else: speech_act = seq_map[i]['speech_act'] tokens = [utils.START_TOKEN] tokens.append(seq_map[i]['speaker_str']) tokens.append(speech_act) tokens.append(quote_start) tokens.extend(seq_map[i]['speech'][1:-1]) tokens.append(quote_end) tokens.append(utils.END_TOKEN) sents.append(tokens) return sents def make_dialogue(self, seeds): """Returns a list of sentences, each being a list of tokens.""" acts = self.make_speech_bits(seeds) seq_map = self.simplify(acts) sents = self.report_seq(seq_map) return(sents) def dev(): import knowledge.names as names mcW = mc.MarkovChain() nm = names.NameMaker() speakers = [nm.random_person() for i in range(1, 4)] dm = dialogue_maker([n['name'] for n in speakers], [n['pronoun'] for n in speakers], mcW) dlg = dm.make_dialogue(["dog", "run", "spot"]) print(dlg) <|fim▁end|>
self.speakers = [{"name": n, "pronoun": p} for n, p in list(zip(names, pronouns))] self._transitions = self.make_transition_probs() self._speech_acts = ["said", "whispered", "shouted", "cried"] self._acts_transitions = [25, 2, 2, 2] self.mc = mc # self.seeds = seeds self.target_len = np.random.randint(5, 50, size=len(names)) # rough words per sentence
<|file_name|>dialogue.py<|end_file_name|><|fim▁begin|>import numpy as np from numpy import cumsum, sum, searchsorted from numpy.random import rand import math import utils import core.sentence as sentence import core.markovchain as mc import logging logger = logging.getLogger(__name__) # Dialogue making class. Need to review where to return a string, where to return a list of tokens, etc. # setters: list of speakers, pronouns, priors etc. # random transitions # Internal: build list of structures: # e.g.{:speaker_name "Alice", :speaker_pronoun "she", :speaker_str "she", :speech_verb "said", :position "end"} # Then end with fn that maps that out to a suitable string # e.g. "<SPEECH>, she said." # External bit then replaces <SPEECH> with a markov-chain-generated sentence (or several). class dialogue_maker(object): """Class to handle creating dialogue based on a list of speakers and a sentence generator.""" def __init__(self, names, pronouns, mc): self.speakers = [{"name": n, "pronoun": p} for n, p in list(zip(names, pronouns))] self._transitions = self.make_transition_probs() self._speech_acts = ["said", "whispered", "shouted", "cried"] self._acts_transitions = [25, 2, 2, 2] self.mc = mc # self.seeds = seeds self.target_len = np.random.randint(5, 50, size=len(names)) # rough words per sentence def make_transition_probs(self): <|fim_middle|> def after(self, speaker_id): """Pick next person to speak""" row = self._transitions[speaker_id] sucessor = searchsorted(cumsum(row), rand() * sum(row)) return sucessor def speaker_sequence(self, speaker_id, n): """Random walk through transitions matrix to produce a sequence of speaker ids""" seq = [] for i in range(n): seq.append(speaker_id) speaker_id = self.after(speaker_id) return seq def speech_sequence(self, n): speech_acts_seq = [] next_speech_id = 0 for i in range(n): next_speech_id = searchsorted(cumsum(self._acts_transitions), rand() * sum(self._acts_transitions)) speech_acts_seq.append(self._speech_acts[next_speech_id]) return speech_acts_seq def seq_to_names(self, sequence): return([self.speakers[id] for id in sequence]) def make_speech_bits(self, seeds): n = len(seeds) speaker_id = self.speaker_sequence(0, n) speech_acts_seq = self.speech_sequence(n) bits = [] ss = sentence.SentenceMaker(self.mc) for i in range(n): sent_toks = ss.generate_sentence_tokens([seeds[i]], self.target_len[speaker_id[i]]) sent_toks = ss.polish_sentence(sent_toks) bits.append({'speaker_name': self.speakers[speaker_id[i]]["name"], 'speech_act': speech_acts_seq[speaker_id[i]], 'seq_id': speaker_id[i], 'speech': sent_toks, 'paragraph': True}) return(bits) def simplify(self, seq_map): "Take a sequence of speech parts and make more natural by removing name reptition etc." for i in range(0, len(seq_map)): seq_map[i]['speaker_str'] = seq_map[i]['speaker_name'] # default # Same speaker contiues: if i > 0 and seq_map[i]['seq_id'] == seq_map[i - 1]['seq_id']: seq_map[i]['speaker_str'] = "" seq_map[i]['speech_act'] = "" seq_map[i]['paragraph'] = False else: if i > 1 and seq_map[i]['seq_id'] == seq_map[i - 2]['seq_id'] \ and seq_map[i]['seq_id'] != seq_map[i - 1]['seq_id']: seq_map[i]['speaker_str'] = "" seq_map[i]['speech_act'] = "" seq_map[i]['paragraph'] = True return seq_map def report_seq(self, seq_map): """Convert sequence of speeches to a tokens.""" sents = [] for i in range(0, len(seq_map)): if seq_map[i]['paragraph']: # text += "\n " quote_start = '"' else: quote_start = "" if i > len(seq_map) - 2 or seq_map[i + 1]['paragraph']: quote_end = '"' else: quote_end = " " if len(seq_map[i]['speech_act']) > 0: speech_act = seq_map[i]['speech_act'] + "," else: speech_act = seq_map[i]['speech_act'] tokens = [utils.START_TOKEN] tokens.append(seq_map[i]['speaker_str']) tokens.append(speech_act) tokens.append(quote_start) tokens.extend(seq_map[i]['speech'][1:-1]) tokens.append(quote_end) tokens.append(utils.END_TOKEN) sents.append(tokens) return sents def make_dialogue(self, seeds): """Returns a list of sentences, each being a list of tokens.""" acts = self.make_speech_bits(seeds) seq_map = self.simplify(acts) sents = self.report_seq(seq_map) return(sents) def dev(): import knowledge.names as names mcW = mc.MarkovChain() nm = names.NameMaker() speakers = [nm.random_person() for i in range(1, 4)] dm = dialogue_maker([n['name'] for n in speakers], [n['pronoun'] for n in speakers], mcW) dlg = dm.make_dialogue(["dog", "run", "spot"]) print(dlg) <|fim▁end|>
"""Make transition matrix between speakers, with random symmetric biases added in""" n = len(self.speakers) # TODO why this line ??? transitions = np.random.randint(5, size=(n, n)) + 1 transitions += transitions.transpose() for i in range(0, math.floor(n / 2)): s1 = np.random.randint(n) s2 = np.random.randint(n) transitions[s1][s2] += 10 transitions[s2][s1] += 8 return(transitions)
<|file_name|>dialogue.py<|end_file_name|><|fim▁begin|>import numpy as np from numpy import cumsum, sum, searchsorted from numpy.random import rand import math import utils import core.sentence as sentence import core.markovchain as mc import logging logger = logging.getLogger(__name__) # Dialogue making class. Need to review where to return a string, where to return a list of tokens, etc. # setters: list of speakers, pronouns, priors etc. # random transitions # Internal: build list of structures: # e.g.{:speaker_name "Alice", :speaker_pronoun "she", :speaker_str "she", :speech_verb "said", :position "end"} # Then end with fn that maps that out to a suitable string # e.g. "<SPEECH>, she said." # External bit then replaces <SPEECH> with a markov-chain-generated sentence (or several). class dialogue_maker(object): """Class to handle creating dialogue based on a list of speakers and a sentence generator.""" def __init__(self, names, pronouns, mc): self.speakers = [{"name": n, "pronoun": p} for n, p in list(zip(names, pronouns))] self._transitions = self.make_transition_probs() self._speech_acts = ["said", "whispered", "shouted", "cried"] self._acts_transitions = [25, 2, 2, 2] self.mc = mc # self.seeds = seeds self.target_len = np.random.randint(5, 50, size=len(names)) # rough words per sentence def make_transition_probs(self): """Make transition matrix between speakers, with random symmetric biases added in""" n = len(self.speakers) # TODO why this line ??? transitions = np.random.randint(5, size=(n, n)) + 1 transitions += transitions.transpose() for i in range(0, math.floor(n / 2)): s1 = np.random.randint(n) s2 = np.random.randint(n) transitions[s1][s2] += 10 transitions[s2][s1] += 8 return(transitions) def after(self, speaker_id): <|fim_middle|> def speaker_sequence(self, speaker_id, n): """Random walk through transitions matrix to produce a sequence of speaker ids""" seq = [] for i in range(n): seq.append(speaker_id) speaker_id = self.after(speaker_id) return seq def speech_sequence(self, n): speech_acts_seq = [] next_speech_id = 0 for i in range(n): next_speech_id = searchsorted(cumsum(self._acts_transitions), rand() * sum(self._acts_transitions)) speech_acts_seq.append(self._speech_acts[next_speech_id]) return speech_acts_seq def seq_to_names(self, sequence): return([self.speakers[id] for id in sequence]) def make_speech_bits(self, seeds): n = len(seeds) speaker_id = self.speaker_sequence(0, n) speech_acts_seq = self.speech_sequence(n) bits = [] ss = sentence.SentenceMaker(self.mc) for i in range(n): sent_toks = ss.generate_sentence_tokens([seeds[i]], self.target_len[speaker_id[i]]) sent_toks = ss.polish_sentence(sent_toks) bits.append({'speaker_name': self.speakers[speaker_id[i]]["name"], 'speech_act': speech_acts_seq[speaker_id[i]], 'seq_id': speaker_id[i], 'speech': sent_toks, 'paragraph': True}) return(bits) def simplify(self, seq_map): "Take a sequence of speech parts and make more natural by removing name reptition etc." for i in range(0, len(seq_map)): seq_map[i]['speaker_str'] = seq_map[i]['speaker_name'] # default # Same speaker contiues: if i > 0 and seq_map[i]['seq_id'] == seq_map[i - 1]['seq_id']: seq_map[i]['speaker_str'] = "" seq_map[i]['speech_act'] = "" seq_map[i]['paragraph'] = False else: if i > 1 and seq_map[i]['seq_id'] == seq_map[i - 2]['seq_id'] \ and seq_map[i]['seq_id'] != seq_map[i - 1]['seq_id']: seq_map[i]['speaker_str'] = "" seq_map[i]['speech_act'] = "" seq_map[i]['paragraph'] = True return seq_map def report_seq(self, seq_map): """Convert sequence of speeches to a tokens.""" sents = [] for i in range(0, len(seq_map)): if seq_map[i]['paragraph']: # text += "\n " quote_start = '"' else: quote_start = "" if i > len(seq_map) - 2 or seq_map[i + 1]['paragraph']: quote_end = '"' else: quote_end = " " if len(seq_map[i]['speech_act']) > 0: speech_act = seq_map[i]['speech_act'] + "," else: speech_act = seq_map[i]['speech_act'] tokens = [utils.START_TOKEN] tokens.append(seq_map[i]['speaker_str']) tokens.append(speech_act) tokens.append(quote_start) tokens.extend(seq_map[i]['speech'][1:-1]) tokens.append(quote_end) tokens.append(utils.END_TOKEN) sents.append(tokens) return sents def make_dialogue(self, seeds): """Returns a list of sentences, each being a list of tokens.""" acts = self.make_speech_bits(seeds) seq_map = self.simplify(acts) sents = self.report_seq(seq_map) return(sents) def dev(): import knowledge.names as names mcW = mc.MarkovChain() nm = names.NameMaker() speakers = [nm.random_person() for i in range(1, 4)] dm = dialogue_maker([n['name'] for n in speakers], [n['pronoun'] for n in speakers], mcW) dlg = dm.make_dialogue(["dog", "run", "spot"]) print(dlg) <|fim▁end|>
"""Pick next person to speak""" row = self._transitions[speaker_id] sucessor = searchsorted(cumsum(row), rand() * sum(row)) return sucessor
<|file_name|>dialogue.py<|end_file_name|><|fim▁begin|>import numpy as np from numpy import cumsum, sum, searchsorted from numpy.random import rand import math import utils import core.sentence as sentence import core.markovchain as mc import logging logger = logging.getLogger(__name__) # Dialogue making class. Need to review where to return a string, where to return a list of tokens, etc. # setters: list of speakers, pronouns, priors etc. # random transitions # Internal: build list of structures: # e.g.{:speaker_name "Alice", :speaker_pronoun "she", :speaker_str "she", :speech_verb "said", :position "end"} # Then end with fn that maps that out to a suitable string # e.g. "<SPEECH>, she said." # External bit then replaces <SPEECH> with a markov-chain-generated sentence (or several). class dialogue_maker(object): """Class to handle creating dialogue based on a list of speakers and a sentence generator.""" def __init__(self, names, pronouns, mc): self.speakers = [{"name": n, "pronoun": p} for n, p in list(zip(names, pronouns))] self._transitions = self.make_transition_probs() self._speech_acts = ["said", "whispered", "shouted", "cried"] self._acts_transitions = [25, 2, 2, 2] self.mc = mc # self.seeds = seeds self.target_len = np.random.randint(5, 50, size=len(names)) # rough words per sentence def make_transition_probs(self): """Make transition matrix between speakers, with random symmetric biases added in""" n = len(self.speakers) # TODO why this line ??? transitions = np.random.randint(5, size=(n, n)) + 1 transitions += transitions.transpose() for i in range(0, math.floor(n / 2)): s1 = np.random.randint(n) s2 = np.random.randint(n) transitions[s1][s2] += 10 transitions[s2][s1] += 8 return(transitions) def after(self, speaker_id): """Pick next person to speak""" row = self._transitions[speaker_id] sucessor = searchsorted(cumsum(row), rand() * sum(row)) return sucessor def speaker_sequence(self, speaker_id, n): <|fim_middle|> def speech_sequence(self, n): speech_acts_seq = [] next_speech_id = 0 for i in range(n): next_speech_id = searchsorted(cumsum(self._acts_transitions), rand() * sum(self._acts_transitions)) speech_acts_seq.append(self._speech_acts[next_speech_id]) return speech_acts_seq def seq_to_names(self, sequence): return([self.speakers[id] for id in sequence]) def make_speech_bits(self, seeds): n = len(seeds) speaker_id = self.speaker_sequence(0, n) speech_acts_seq = self.speech_sequence(n) bits = [] ss = sentence.SentenceMaker(self.mc) for i in range(n): sent_toks = ss.generate_sentence_tokens([seeds[i]], self.target_len[speaker_id[i]]) sent_toks = ss.polish_sentence(sent_toks) bits.append({'speaker_name': self.speakers[speaker_id[i]]["name"], 'speech_act': speech_acts_seq[speaker_id[i]], 'seq_id': speaker_id[i], 'speech': sent_toks, 'paragraph': True}) return(bits) def simplify(self, seq_map): "Take a sequence of speech parts and make more natural by removing name reptition etc." for i in range(0, len(seq_map)): seq_map[i]['speaker_str'] = seq_map[i]['speaker_name'] # default # Same speaker contiues: if i > 0 and seq_map[i]['seq_id'] == seq_map[i - 1]['seq_id']: seq_map[i]['speaker_str'] = "" seq_map[i]['speech_act'] = "" seq_map[i]['paragraph'] = False else: if i > 1 and seq_map[i]['seq_id'] == seq_map[i - 2]['seq_id'] \ and seq_map[i]['seq_id'] != seq_map[i - 1]['seq_id']: seq_map[i]['speaker_str'] = "" seq_map[i]['speech_act'] = "" seq_map[i]['paragraph'] = True return seq_map def report_seq(self, seq_map): """Convert sequence of speeches to a tokens.""" sents = [] for i in range(0, len(seq_map)): if seq_map[i]['paragraph']: # text += "\n " quote_start = '"' else: quote_start = "" if i > len(seq_map) - 2 or seq_map[i + 1]['paragraph']: quote_end = '"' else: quote_end = " " if len(seq_map[i]['speech_act']) > 0: speech_act = seq_map[i]['speech_act'] + "," else: speech_act = seq_map[i]['speech_act'] tokens = [utils.START_TOKEN] tokens.append(seq_map[i]['speaker_str']) tokens.append(speech_act) tokens.append(quote_start) tokens.extend(seq_map[i]['speech'][1:-1]) tokens.append(quote_end) tokens.append(utils.END_TOKEN) sents.append(tokens) return sents def make_dialogue(self, seeds): """Returns a list of sentences, each being a list of tokens.""" acts = self.make_speech_bits(seeds) seq_map = self.simplify(acts) sents = self.report_seq(seq_map) return(sents) def dev(): import knowledge.names as names mcW = mc.MarkovChain() nm = names.NameMaker() speakers = [nm.random_person() for i in range(1, 4)] dm = dialogue_maker([n['name'] for n in speakers], [n['pronoun'] for n in speakers], mcW) dlg = dm.make_dialogue(["dog", "run", "spot"]) print(dlg) <|fim▁end|>
"""Random walk through transitions matrix to produce a sequence of speaker ids""" seq = [] for i in range(n): seq.append(speaker_id) speaker_id = self.after(speaker_id) return seq
<|file_name|>dialogue.py<|end_file_name|><|fim▁begin|>import numpy as np from numpy import cumsum, sum, searchsorted from numpy.random import rand import math import utils import core.sentence as sentence import core.markovchain as mc import logging logger = logging.getLogger(__name__) # Dialogue making class. Need to review where to return a string, where to return a list of tokens, etc. # setters: list of speakers, pronouns, priors etc. # random transitions # Internal: build list of structures: # e.g.{:speaker_name "Alice", :speaker_pronoun "she", :speaker_str "she", :speech_verb "said", :position "end"} # Then end with fn that maps that out to a suitable string # e.g. "<SPEECH>, she said." # External bit then replaces <SPEECH> with a markov-chain-generated sentence (or several). class dialogue_maker(object): """Class to handle creating dialogue based on a list of speakers and a sentence generator.""" def __init__(self, names, pronouns, mc): self.speakers = [{"name": n, "pronoun": p} for n, p in list(zip(names, pronouns))] self._transitions = self.make_transition_probs() self._speech_acts = ["said", "whispered", "shouted", "cried"] self._acts_transitions = [25, 2, 2, 2] self.mc = mc # self.seeds = seeds self.target_len = np.random.randint(5, 50, size=len(names)) # rough words per sentence def make_transition_probs(self): """Make transition matrix between speakers, with random symmetric biases added in""" n = len(self.speakers) # TODO why this line ??? transitions = np.random.randint(5, size=(n, n)) + 1 transitions += transitions.transpose() for i in range(0, math.floor(n / 2)): s1 = np.random.randint(n) s2 = np.random.randint(n) transitions[s1][s2] += 10 transitions[s2][s1] += 8 return(transitions) def after(self, speaker_id): """Pick next person to speak""" row = self._transitions[speaker_id] sucessor = searchsorted(cumsum(row), rand() * sum(row)) return sucessor def speaker_sequence(self, speaker_id, n): """Random walk through transitions matrix to produce a sequence of speaker ids""" seq = [] for i in range(n): seq.append(speaker_id) speaker_id = self.after(speaker_id) return seq def speech_sequence(self, n): <|fim_middle|> def seq_to_names(self, sequence): return([self.speakers[id] for id in sequence]) def make_speech_bits(self, seeds): n = len(seeds) speaker_id = self.speaker_sequence(0, n) speech_acts_seq = self.speech_sequence(n) bits = [] ss = sentence.SentenceMaker(self.mc) for i in range(n): sent_toks = ss.generate_sentence_tokens([seeds[i]], self.target_len[speaker_id[i]]) sent_toks = ss.polish_sentence(sent_toks) bits.append({'speaker_name': self.speakers[speaker_id[i]]["name"], 'speech_act': speech_acts_seq[speaker_id[i]], 'seq_id': speaker_id[i], 'speech': sent_toks, 'paragraph': True}) return(bits) def simplify(self, seq_map): "Take a sequence of speech parts and make more natural by removing name reptition etc." for i in range(0, len(seq_map)): seq_map[i]['speaker_str'] = seq_map[i]['speaker_name'] # default # Same speaker contiues: if i > 0 and seq_map[i]['seq_id'] == seq_map[i - 1]['seq_id']: seq_map[i]['speaker_str'] = "" seq_map[i]['speech_act'] = "" seq_map[i]['paragraph'] = False else: if i > 1 and seq_map[i]['seq_id'] == seq_map[i - 2]['seq_id'] \ and seq_map[i]['seq_id'] != seq_map[i - 1]['seq_id']: seq_map[i]['speaker_str'] = "" seq_map[i]['speech_act'] = "" seq_map[i]['paragraph'] = True return seq_map def report_seq(self, seq_map): """Convert sequence of speeches to a tokens.""" sents = [] for i in range(0, len(seq_map)): if seq_map[i]['paragraph']: # text += "\n " quote_start = '"' else: quote_start = "" if i > len(seq_map) - 2 or seq_map[i + 1]['paragraph']: quote_end = '"' else: quote_end = " " if len(seq_map[i]['speech_act']) > 0: speech_act = seq_map[i]['speech_act'] + "," else: speech_act = seq_map[i]['speech_act'] tokens = [utils.START_TOKEN] tokens.append(seq_map[i]['speaker_str']) tokens.append(speech_act) tokens.append(quote_start) tokens.extend(seq_map[i]['speech'][1:-1]) tokens.append(quote_end) tokens.append(utils.END_TOKEN) sents.append(tokens) return sents def make_dialogue(self, seeds): """Returns a list of sentences, each being a list of tokens.""" acts = self.make_speech_bits(seeds) seq_map = self.simplify(acts) sents = self.report_seq(seq_map) return(sents) def dev(): import knowledge.names as names mcW = mc.MarkovChain() nm = names.NameMaker() speakers = [nm.random_person() for i in range(1, 4)] dm = dialogue_maker([n['name'] for n in speakers], [n['pronoun'] for n in speakers], mcW) dlg = dm.make_dialogue(["dog", "run", "spot"]) print(dlg) <|fim▁end|>
speech_acts_seq = [] next_speech_id = 0 for i in range(n): next_speech_id = searchsorted(cumsum(self._acts_transitions), rand() * sum(self._acts_transitions)) speech_acts_seq.append(self._speech_acts[next_speech_id]) return speech_acts_seq
<|file_name|>dialogue.py<|end_file_name|><|fim▁begin|>import numpy as np from numpy import cumsum, sum, searchsorted from numpy.random import rand import math import utils import core.sentence as sentence import core.markovchain as mc import logging logger = logging.getLogger(__name__) # Dialogue making class. Need to review where to return a string, where to return a list of tokens, etc. # setters: list of speakers, pronouns, priors etc. # random transitions # Internal: build list of structures: # e.g.{:speaker_name "Alice", :speaker_pronoun "she", :speaker_str "she", :speech_verb "said", :position "end"} # Then end with fn that maps that out to a suitable string # e.g. "<SPEECH>, she said." # External bit then replaces <SPEECH> with a markov-chain-generated sentence (or several). class dialogue_maker(object): """Class to handle creating dialogue based on a list of speakers and a sentence generator.""" def __init__(self, names, pronouns, mc): self.speakers = [{"name": n, "pronoun": p} for n, p in list(zip(names, pronouns))] self._transitions = self.make_transition_probs() self._speech_acts = ["said", "whispered", "shouted", "cried"] self._acts_transitions = [25, 2, 2, 2] self.mc = mc # self.seeds = seeds self.target_len = np.random.randint(5, 50, size=len(names)) # rough words per sentence def make_transition_probs(self): """Make transition matrix between speakers, with random symmetric biases added in""" n = len(self.speakers) # TODO why this line ??? transitions = np.random.randint(5, size=(n, n)) + 1 transitions += transitions.transpose() for i in range(0, math.floor(n / 2)): s1 = np.random.randint(n) s2 = np.random.randint(n) transitions[s1][s2] += 10 transitions[s2][s1] += 8 return(transitions) def after(self, speaker_id): """Pick next person to speak""" row = self._transitions[speaker_id] sucessor = searchsorted(cumsum(row), rand() * sum(row)) return sucessor def speaker_sequence(self, speaker_id, n): """Random walk through transitions matrix to produce a sequence of speaker ids""" seq = [] for i in range(n): seq.append(speaker_id) speaker_id = self.after(speaker_id) return seq def speech_sequence(self, n): speech_acts_seq = [] next_speech_id = 0 for i in range(n): next_speech_id = searchsorted(cumsum(self._acts_transitions), rand() * sum(self._acts_transitions)) speech_acts_seq.append(self._speech_acts[next_speech_id]) return speech_acts_seq def seq_to_names(self, sequence): <|fim_middle|> def make_speech_bits(self, seeds): n = len(seeds) speaker_id = self.speaker_sequence(0, n) speech_acts_seq = self.speech_sequence(n) bits = [] ss = sentence.SentenceMaker(self.mc) for i in range(n): sent_toks = ss.generate_sentence_tokens([seeds[i]], self.target_len[speaker_id[i]]) sent_toks = ss.polish_sentence(sent_toks) bits.append({'speaker_name': self.speakers[speaker_id[i]]["name"], 'speech_act': speech_acts_seq[speaker_id[i]], 'seq_id': speaker_id[i], 'speech': sent_toks, 'paragraph': True}) return(bits) def simplify(self, seq_map): "Take a sequence of speech parts and make more natural by removing name reptition etc." for i in range(0, len(seq_map)): seq_map[i]['speaker_str'] = seq_map[i]['speaker_name'] # default # Same speaker contiues: if i > 0 and seq_map[i]['seq_id'] == seq_map[i - 1]['seq_id']: seq_map[i]['speaker_str'] = "" seq_map[i]['speech_act'] = "" seq_map[i]['paragraph'] = False else: if i > 1 and seq_map[i]['seq_id'] == seq_map[i - 2]['seq_id'] \ and seq_map[i]['seq_id'] != seq_map[i - 1]['seq_id']: seq_map[i]['speaker_str'] = "" seq_map[i]['speech_act'] = "" seq_map[i]['paragraph'] = True return seq_map def report_seq(self, seq_map): """Convert sequence of speeches to a tokens.""" sents = [] for i in range(0, len(seq_map)): if seq_map[i]['paragraph']: # text += "\n " quote_start = '"' else: quote_start = "" if i > len(seq_map) - 2 or seq_map[i + 1]['paragraph']: quote_end = '"' else: quote_end = " " if len(seq_map[i]['speech_act']) > 0: speech_act = seq_map[i]['speech_act'] + "," else: speech_act = seq_map[i]['speech_act'] tokens = [utils.START_TOKEN] tokens.append(seq_map[i]['speaker_str']) tokens.append(speech_act) tokens.append(quote_start) tokens.extend(seq_map[i]['speech'][1:-1]) tokens.append(quote_end) tokens.append(utils.END_TOKEN) sents.append(tokens) return sents def make_dialogue(self, seeds): """Returns a list of sentences, each being a list of tokens.""" acts = self.make_speech_bits(seeds) seq_map = self.simplify(acts) sents = self.report_seq(seq_map) return(sents) def dev(): import knowledge.names as names mcW = mc.MarkovChain() nm = names.NameMaker() speakers = [nm.random_person() for i in range(1, 4)] dm = dialogue_maker([n['name'] for n in speakers], [n['pronoun'] for n in speakers], mcW) dlg = dm.make_dialogue(["dog", "run", "spot"]) print(dlg) <|fim▁end|>
return([self.speakers[id] for id in sequence])
<|file_name|>dialogue.py<|end_file_name|><|fim▁begin|>import numpy as np from numpy import cumsum, sum, searchsorted from numpy.random import rand import math import utils import core.sentence as sentence import core.markovchain as mc import logging logger = logging.getLogger(__name__) # Dialogue making class. Need to review where to return a string, where to return a list of tokens, etc. # setters: list of speakers, pronouns, priors etc. # random transitions # Internal: build list of structures: # e.g.{:speaker_name "Alice", :speaker_pronoun "she", :speaker_str "she", :speech_verb "said", :position "end"} # Then end with fn that maps that out to a suitable string # e.g. "<SPEECH>, she said." # External bit then replaces <SPEECH> with a markov-chain-generated sentence (or several). class dialogue_maker(object): """Class to handle creating dialogue based on a list of speakers and a sentence generator.""" def __init__(self, names, pronouns, mc): self.speakers = [{"name": n, "pronoun": p} for n, p in list(zip(names, pronouns))] self._transitions = self.make_transition_probs() self._speech_acts = ["said", "whispered", "shouted", "cried"] self._acts_transitions = [25, 2, 2, 2] self.mc = mc # self.seeds = seeds self.target_len = np.random.randint(5, 50, size=len(names)) # rough words per sentence def make_transition_probs(self): """Make transition matrix between speakers, with random symmetric biases added in""" n = len(self.speakers) # TODO why this line ??? transitions = np.random.randint(5, size=(n, n)) + 1 transitions += transitions.transpose() for i in range(0, math.floor(n / 2)): s1 = np.random.randint(n) s2 = np.random.randint(n) transitions[s1][s2] += 10 transitions[s2][s1] += 8 return(transitions) def after(self, speaker_id): """Pick next person to speak""" row = self._transitions[speaker_id] sucessor = searchsorted(cumsum(row), rand() * sum(row)) return sucessor def speaker_sequence(self, speaker_id, n): """Random walk through transitions matrix to produce a sequence of speaker ids""" seq = [] for i in range(n): seq.append(speaker_id) speaker_id = self.after(speaker_id) return seq def speech_sequence(self, n): speech_acts_seq = [] next_speech_id = 0 for i in range(n): next_speech_id = searchsorted(cumsum(self._acts_transitions), rand() * sum(self._acts_transitions)) speech_acts_seq.append(self._speech_acts[next_speech_id]) return speech_acts_seq def seq_to_names(self, sequence): return([self.speakers[id] for id in sequence]) def make_speech_bits(self, seeds): <|fim_middle|> def simplify(self, seq_map): "Take a sequence of speech parts and make more natural by removing name reptition etc." for i in range(0, len(seq_map)): seq_map[i]['speaker_str'] = seq_map[i]['speaker_name'] # default # Same speaker contiues: if i > 0 and seq_map[i]['seq_id'] == seq_map[i - 1]['seq_id']: seq_map[i]['speaker_str'] = "" seq_map[i]['speech_act'] = "" seq_map[i]['paragraph'] = False else: if i > 1 and seq_map[i]['seq_id'] == seq_map[i - 2]['seq_id'] \ and seq_map[i]['seq_id'] != seq_map[i - 1]['seq_id']: seq_map[i]['speaker_str'] = "" seq_map[i]['speech_act'] = "" seq_map[i]['paragraph'] = True return seq_map def report_seq(self, seq_map): """Convert sequence of speeches to a tokens.""" sents = [] for i in range(0, len(seq_map)): if seq_map[i]['paragraph']: # text += "\n " quote_start = '"' else: quote_start = "" if i > len(seq_map) - 2 or seq_map[i + 1]['paragraph']: quote_end = '"' else: quote_end = " " if len(seq_map[i]['speech_act']) > 0: speech_act = seq_map[i]['speech_act'] + "," else: speech_act = seq_map[i]['speech_act'] tokens = [utils.START_TOKEN] tokens.append(seq_map[i]['speaker_str']) tokens.append(speech_act) tokens.append(quote_start) tokens.extend(seq_map[i]['speech'][1:-1]) tokens.append(quote_end) tokens.append(utils.END_TOKEN) sents.append(tokens) return sents def make_dialogue(self, seeds): """Returns a list of sentences, each being a list of tokens.""" acts = self.make_speech_bits(seeds) seq_map = self.simplify(acts) sents = self.report_seq(seq_map) return(sents) def dev(): import knowledge.names as names mcW = mc.MarkovChain() nm = names.NameMaker() speakers = [nm.random_person() for i in range(1, 4)] dm = dialogue_maker([n['name'] for n in speakers], [n['pronoun'] for n in speakers], mcW) dlg = dm.make_dialogue(["dog", "run", "spot"]) print(dlg) <|fim▁end|>
n = len(seeds) speaker_id = self.speaker_sequence(0, n) speech_acts_seq = self.speech_sequence(n) bits = [] ss = sentence.SentenceMaker(self.mc) for i in range(n): sent_toks = ss.generate_sentence_tokens([seeds[i]], self.target_len[speaker_id[i]]) sent_toks = ss.polish_sentence(sent_toks) bits.append({'speaker_name': self.speakers[speaker_id[i]]["name"], 'speech_act': speech_acts_seq[speaker_id[i]], 'seq_id': speaker_id[i], 'speech': sent_toks, 'paragraph': True}) return(bits)
<|file_name|>dialogue.py<|end_file_name|><|fim▁begin|>import numpy as np from numpy import cumsum, sum, searchsorted from numpy.random import rand import math import utils import core.sentence as sentence import core.markovchain as mc import logging logger = logging.getLogger(__name__) # Dialogue making class. Need to review where to return a string, where to return a list of tokens, etc. # setters: list of speakers, pronouns, priors etc. # random transitions # Internal: build list of structures: # e.g.{:speaker_name "Alice", :speaker_pronoun "she", :speaker_str "she", :speech_verb "said", :position "end"} # Then end with fn that maps that out to a suitable string # e.g. "<SPEECH>, she said." # External bit then replaces <SPEECH> with a markov-chain-generated sentence (or several). class dialogue_maker(object): """Class to handle creating dialogue based on a list of speakers and a sentence generator.""" def __init__(self, names, pronouns, mc): self.speakers = [{"name": n, "pronoun": p} for n, p in list(zip(names, pronouns))] self._transitions = self.make_transition_probs() self._speech_acts = ["said", "whispered", "shouted", "cried"] self._acts_transitions = [25, 2, 2, 2] self.mc = mc # self.seeds = seeds self.target_len = np.random.randint(5, 50, size=len(names)) # rough words per sentence def make_transition_probs(self): """Make transition matrix between speakers, with random symmetric biases added in""" n = len(self.speakers) # TODO why this line ??? transitions = np.random.randint(5, size=(n, n)) + 1 transitions += transitions.transpose() for i in range(0, math.floor(n / 2)): s1 = np.random.randint(n) s2 = np.random.randint(n) transitions[s1][s2] += 10 transitions[s2][s1] += 8 return(transitions) def after(self, speaker_id): """Pick next person to speak""" row = self._transitions[speaker_id] sucessor = searchsorted(cumsum(row), rand() * sum(row)) return sucessor def speaker_sequence(self, speaker_id, n): """Random walk through transitions matrix to produce a sequence of speaker ids""" seq = [] for i in range(n): seq.append(speaker_id) speaker_id = self.after(speaker_id) return seq def speech_sequence(self, n): speech_acts_seq = [] next_speech_id = 0 for i in range(n): next_speech_id = searchsorted(cumsum(self._acts_transitions), rand() * sum(self._acts_transitions)) speech_acts_seq.append(self._speech_acts[next_speech_id]) return speech_acts_seq def seq_to_names(self, sequence): return([self.speakers[id] for id in sequence]) def make_speech_bits(self, seeds): n = len(seeds) speaker_id = self.speaker_sequence(0, n) speech_acts_seq = self.speech_sequence(n) bits = [] ss = sentence.SentenceMaker(self.mc) for i in range(n): sent_toks = ss.generate_sentence_tokens([seeds[i]], self.target_len[speaker_id[i]]) sent_toks = ss.polish_sentence(sent_toks) bits.append({'speaker_name': self.speakers[speaker_id[i]]["name"], 'speech_act': speech_acts_seq[speaker_id[i]], 'seq_id': speaker_id[i], 'speech': sent_toks, 'paragraph': True}) return(bits) def simplify(self, seq_map): <|fim_middle|> def report_seq(self, seq_map): """Convert sequence of speeches to a tokens.""" sents = [] for i in range(0, len(seq_map)): if seq_map[i]['paragraph']: # text += "\n " quote_start = '"' else: quote_start = "" if i > len(seq_map) - 2 or seq_map[i + 1]['paragraph']: quote_end = '"' else: quote_end = " " if len(seq_map[i]['speech_act']) > 0: speech_act = seq_map[i]['speech_act'] + "," else: speech_act = seq_map[i]['speech_act'] tokens = [utils.START_TOKEN] tokens.append(seq_map[i]['speaker_str']) tokens.append(speech_act) tokens.append(quote_start) tokens.extend(seq_map[i]['speech'][1:-1]) tokens.append(quote_end) tokens.append(utils.END_TOKEN) sents.append(tokens) return sents def make_dialogue(self, seeds): """Returns a list of sentences, each being a list of tokens.""" acts = self.make_speech_bits(seeds) seq_map = self.simplify(acts) sents = self.report_seq(seq_map) return(sents) def dev(): import knowledge.names as names mcW = mc.MarkovChain() nm = names.NameMaker() speakers = [nm.random_person() for i in range(1, 4)] dm = dialogue_maker([n['name'] for n in speakers], [n['pronoun'] for n in speakers], mcW) dlg = dm.make_dialogue(["dog", "run", "spot"]) print(dlg) <|fim▁end|>
"Take a sequence of speech parts and make more natural by removing name reptition etc." for i in range(0, len(seq_map)): seq_map[i]['speaker_str'] = seq_map[i]['speaker_name'] # default # Same speaker contiues: if i > 0 and seq_map[i]['seq_id'] == seq_map[i - 1]['seq_id']: seq_map[i]['speaker_str'] = "" seq_map[i]['speech_act'] = "" seq_map[i]['paragraph'] = False else: if i > 1 and seq_map[i]['seq_id'] == seq_map[i - 2]['seq_id'] \ and seq_map[i]['seq_id'] != seq_map[i - 1]['seq_id']: seq_map[i]['speaker_str'] = "" seq_map[i]['speech_act'] = "" seq_map[i]['paragraph'] = True return seq_map
<|file_name|>dialogue.py<|end_file_name|><|fim▁begin|>import numpy as np from numpy import cumsum, sum, searchsorted from numpy.random import rand import math import utils import core.sentence as sentence import core.markovchain as mc import logging logger = logging.getLogger(__name__) # Dialogue making class. Need to review where to return a string, where to return a list of tokens, etc. # setters: list of speakers, pronouns, priors etc. # random transitions # Internal: build list of structures: # e.g.{:speaker_name "Alice", :speaker_pronoun "she", :speaker_str "she", :speech_verb "said", :position "end"} # Then end with fn that maps that out to a suitable string # e.g. "<SPEECH>, she said." # External bit then replaces <SPEECH> with a markov-chain-generated sentence (or several). class dialogue_maker(object): """Class to handle creating dialogue based on a list of speakers and a sentence generator.""" def __init__(self, names, pronouns, mc): self.speakers = [{"name": n, "pronoun": p} for n, p in list(zip(names, pronouns))] self._transitions = self.make_transition_probs() self._speech_acts = ["said", "whispered", "shouted", "cried"] self._acts_transitions = [25, 2, 2, 2] self.mc = mc # self.seeds = seeds self.target_len = np.random.randint(5, 50, size=len(names)) # rough words per sentence def make_transition_probs(self): """Make transition matrix between speakers, with random symmetric biases added in""" n = len(self.speakers) # TODO why this line ??? transitions = np.random.randint(5, size=(n, n)) + 1 transitions += transitions.transpose() for i in range(0, math.floor(n / 2)): s1 = np.random.randint(n) s2 = np.random.randint(n) transitions[s1][s2] += 10 transitions[s2][s1] += 8 return(transitions) def after(self, speaker_id): """Pick next person to speak""" row = self._transitions[speaker_id] sucessor = searchsorted(cumsum(row), rand() * sum(row)) return sucessor def speaker_sequence(self, speaker_id, n): """Random walk through transitions matrix to produce a sequence of speaker ids""" seq = [] for i in range(n): seq.append(speaker_id) speaker_id = self.after(speaker_id) return seq def speech_sequence(self, n): speech_acts_seq = [] next_speech_id = 0 for i in range(n): next_speech_id = searchsorted(cumsum(self._acts_transitions), rand() * sum(self._acts_transitions)) speech_acts_seq.append(self._speech_acts[next_speech_id]) return speech_acts_seq def seq_to_names(self, sequence): return([self.speakers[id] for id in sequence]) def make_speech_bits(self, seeds): n = len(seeds) speaker_id = self.speaker_sequence(0, n) speech_acts_seq = self.speech_sequence(n) bits = [] ss = sentence.SentenceMaker(self.mc) for i in range(n): sent_toks = ss.generate_sentence_tokens([seeds[i]], self.target_len[speaker_id[i]]) sent_toks = ss.polish_sentence(sent_toks) bits.append({'speaker_name': self.speakers[speaker_id[i]]["name"], 'speech_act': speech_acts_seq[speaker_id[i]], 'seq_id': speaker_id[i], 'speech': sent_toks, 'paragraph': True}) return(bits) def simplify(self, seq_map): "Take a sequence of speech parts and make more natural by removing name reptition etc." for i in range(0, len(seq_map)): seq_map[i]['speaker_str'] = seq_map[i]['speaker_name'] # default # Same speaker contiues: if i > 0 and seq_map[i]['seq_id'] == seq_map[i - 1]['seq_id']: seq_map[i]['speaker_str'] = "" seq_map[i]['speech_act'] = "" seq_map[i]['paragraph'] = False else: if i > 1 and seq_map[i]['seq_id'] == seq_map[i - 2]['seq_id'] \ and seq_map[i]['seq_id'] != seq_map[i - 1]['seq_id']: seq_map[i]['speaker_str'] = "" seq_map[i]['speech_act'] = "" seq_map[i]['paragraph'] = True return seq_map def report_seq(self, seq_map): <|fim_middle|> def make_dialogue(self, seeds): """Returns a list of sentences, each being a list of tokens.""" acts = self.make_speech_bits(seeds) seq_map = self.simplify(acts) sents = self.report_seq(seq_map) return(sents) def dev(): import knowledge.names as names mcW = mc.MarkovChain() nm = names.NameMaker() speakers = [nm.random_person() for i in range(1, 4)] dm = dialogue_maker([n['name'] for n in speakers], [n['pronoun'] for n in speakers], mcW) dlg = dm.make_dialogue(["dog", "run", "spot"]) print(dlg) <|fim▁end|>
"""Convert sequence of speeches to a tokens.""" sents = [] for i in range(0, len(seq_map)): if seq_map[i]['paragraph']: # text += "\n " quote_start = '"' else: quote_start = "" if i > len(seq_map) - 2 or seq_map[i + 1]['paragraph']: quote_end = '"' else: quote_end = " " if len(seq_map[i]['speech_act']) > 0: speech_act = seq_map[i]['speech_act'] + "," else: speech_act = seq_map[i]['speech_act'] tokens = [utils.START_TOKEN] tokens.append(seq_map[i]['speaker_str']) tokens.append(speech_act) tokens.append(quote_start) tokens.extend(seq_map[i]['speech'][1:-1]) tokens.append(quote_end) tokens.append(utils.END_TOKEN) sents.append(tokens) return sents
<|file_name|>dialogue.py<|end_file_name|><|fim▁begin|>import numpy as np from numpy import cumsum, sum, searchsorted from numpy.random import rand import math import utils import core.sentence as sentence import core.markovchain as mc import logging logger = logging.getLogger(__name__) # Dialogue making class. Need to review where to return a string, where to return a list of tokens, etc. # setters: list of speakers, pronouns, priors etc. # random transitions # Internal: build list of structures: # e.g.{:speaker_name "Alice", :speaker_pronoun "she", :speaker_str "she", :speech_verb "said", :position "end"} # Then end with fn that maps that out to a suitable string # e.g. "<SPEECH>, she said." # External bit then replaces <SPEECH> with a markov-chain-generated sentence (or several). class dialogue_maker(object): """Class to handle creating dialogue based on a list of speakers and a sentence generator.""" def __init__(self, names, pronouns, mc): self.speakers = [{"name": n, "pronoun": p} for n, p in list(zip(names, pronouns))] self._transitions = self.make_transition_probs() self._speech_acts = ["said", "whispered", "shouted", "cried"] self._acts_transitions = [25, 2, 2, 2] self.mc = mc # self.seeds = seeds self.target_len = np.random.randint(5, 50, size=len(names)) # rough words per sentence def make_transition_probs(self): """Make transition matrix between speakers, with random symmetric biases added in""" n = len(self.speakers) # TODO why this line ??? transitions = np.random.randint(5, size=(n, n)) + 1 transitions += transitions.transpose() for i in range(0, math.floor(n / 2)): s1 = np.random.randint(n) s2 = np.random.randint(n) transitions[s1][s2] += 10 transitions[s2][s1] += 8 return(transitions) def after(self, speaker_id): """Pick next person to speak""" row = self._transitions[speaker_id] sucessor = searchsorted(cumsum(row), rand() * sum(row)) return sucessor def speaker_sequence(self, speaker_id, n): """Random walk through transitions matrix to produce a sequence of speaker ids""" seq = [] for i in range(n): seq.append(speaker_id) speaker_id = self.after(speaker_id) return seq def speech_sequence(self, n): speech_acts_seq = [] next_speech_id = 0 for i in range(n): next_speech_id = searchsorted(cumsum(self._acts_transitions), rand() * sum(self._acts_transitions)) speech_acts_seq.append(self._speech_acts[next_speech_id]) return speech_acts_seq def seq_to_names(self, sequence): return([self.speakers[id] for id in sequence]) def make_speech_bits(self, seeds): n = len(seeds) speaker_id = self.speaker_sequence(0, n) speech_acts_seq = self.speech_sequence(n) bits = [] ss = sentence.SentenceMaker(self.mc) for i in range(n): sent_toks = ss.generate_sentence_tokens([seeds[i]], self.target_len[speaker_id[i]]) sent_toks = ss.polish_sentence(sent_toks) bits.append({'speaker_name': self.speakers[speaker_id[i]]["name"], 'speech_act': speech_acts_seq[speaker_id[i]], 'seq_id': speaker_id[i], 'speech': sent_toks, 'paragraph': True}) return(bits) def simplify(self, seq_map): "Take a sequence of speech parts and make more natural by removing name reptition etc." for i in range(0, len(seq_map)): seq_map[i]['speaker_str'] = seq_map[i]['speaker_name'] # default # Same speaker contiues: if i > 0 and seq_map[i]['seq_id'] == seq_map[i - 1]['seq_id']: seq_map[i]['speaker_str'] = "" seq_map[i]['speech_act'] = "" seq_map[i]['paragraph'] = False else: if i > 1 and seq_map[i]['seq_id'] == seq_map[i - 2]['seq_id'] \ and seq_map[i]['seq_id'] != seq_map[i - 1]['seq_id']: seq_map[i]['speaker_str'] = "" seq_map[i]['speech_act'] = "" seq_map[i]['paragraph'] = True return seq_map def report_seq(self, seq_map): """Convert sequence of speeches to a tokens.""" sents = [] for i in range(0, len(seq_map)): if seq_map[i]['paragraph']: # text += "\n " quote_start = '"' else: quote_start = "" if i > len(seq_map) - 2 or seq_map[i + 1]['paragraph']: quote_end = '"' else: quote_end = " " if len(seq_map[i]['speech_act']) > 0: speech_act = seq_map[i]['speech_act'] + "," else: speech_act = seq_map[i]['speech_act'] tokens = [utils.START_TOKEN] tokens.append(seq_map[i]['speaker_str']) tokens.append(speech_act) tokens.append(quote_start) tokens.extend(seq_map[i]['speech'][1:-1]) tokens.append(quote_end) tokens.append(utils.END_TOKEN) sents.append(tokens) return sents def make_dialogue(self, seeds): <|fim_middle|> def dev(): import knowledge.names as names mcW = mc.MarkovChain() nm = names.NameMaker() speakers = [nm.random_person() for i in range(1, 4)] dm = dialogue_maker([n['name'] for n in speakers], [n['pronoun'] for n in speakers], mcW) dlg = dm.make_dialogue(["dog", "run", "spot"]) print(dlg) <|fim▁end|>
"""Returns a list of sentences, each being a list of tokens.""" acts = self.make_speech_bits(seeds) seq_map = self.simplify(acts) sents = self.report_seq(seq_map) return(sents)
<|file_name|>dialogue.py<|end_file_name|><|fim▁begin|>import numpy as np from numpy import cumsum, sum, searchsorted from numpy.random import rand import math import utils import core.sentence as sentence import core.markovchain as mc import logging logger = logging.getLogger(__name__) # Dialogue making class. Need to review where to return a string, where to return a list of tokens, etc. # setters: list of speakers, pronouns, priors etc. # random transitions # Internal: build list of structures: # e.g.{:speaker_name "Alice", :speaker_pronoun "she", :speaker_str "she", :speech_verb "said", :position "end"} # Then end with fn that maps that out to a suitable string # e.g. "<SPEECH>, she said." # External bit then replaces <SPEECH> with a markov-chain-generated sentence (or several). class dialogue_maker(object): """Class to handle creating dialogue based on a list of speakers and a sentence generator.""" def __init__(self, names, pronouns, mc): self.speakers = [{"name": n, "pronoun": p} for n, p in list(zip(names, pronouns))] self._transitions = self.make_transition_probs() self._speech_acts = ["said", "whispered", "shouted", "cried"] self._acts_transitions = [25, 2, 2, 2] self.mc = mc # self.seeds = seeds self.target_len = np.random.randint(5, 50, size=len(names)) # rough words per sentence def make_transition_probs(self): """Make transition matrix between speakers, with random symmetric biases added in""" n = len(self.speakers) # TODO why this line ??? transitions = np.random.randint(5, size=(n, n)) + 1 transitions += transitions.transpose() for i in range(0, math.floor(n / 2)): s1 = np.random.randint(n) s2 = np.random.randint(n) transitions[s1][s2] += 10 transitions[s2][s1] += 8 return(transitions) def after(self, speaker_id): """Pick next person to speak""" row = self._transitions[speaker_id] sucessor = searchsorted(cumsum(row), rand() * sum(row)) return sucessor def speaker_sequence(self, speaker_id, n): """Random walk through transitions matrix to produce a sequence of speaker ids""" seq = [] for i in range(n): seq.append(speaker_id) speaker_id = self.after(speaker_id) return seq def speech_sequence(self, n): speech_acts_seq = [] next_speech_id = 0 for i in range(n): next_speech_id = searchsorted(cumsum(self._acts_transitions), rand() * sum(self._acts_transitions)) speech_acts_seq.append(self._speech_acts[next_speech_id]) return speech_acts_seq def seq_to_names(self, sequence): return([self.speakers[id] for id in sequence]) def make_speech_bits(self, seeds): n = len(seeds) speaker_id = self.speaker_sequence(0, n) speech_acts_seq = self.speech_sequence(n) bits = [] ss = sentence.SentenceMaker(self.mc) for i in range(n): sent_toks = ss.generate_sentence_tokens([seeds[i]], self.target_len[speaker_id[i]]) sent_toks = ss.polish_sentence(sent_toks) bits.append({'speaker_name': self.speakers[speaker_id[i]]["name"], 'speech_act': speech_acts_seq[speaker_id[i]], 'seq_id': speaker_id[i], 'speech': sent_toks, 'paragraph': True}) return(bits) def simplify(self, seq_map): "Take a sequence of speech parts and make more natural by removing name reptition etc." for i in range(0, len(seq_map)): seq_map[i]['speaker_str'] = seq_map[i]['speaker_name'] # default # Same speaker contiues: if i > 0 and seq_map[i]['seq_id'] == seq_map[i - 1]['seq_id']: seq_map[i]['speaker_str'] = "" seq_map[i]['speech_act'] = "" seq_map[i]['paragraph'] = False else: if i > 1 and seq_map[i]['seq_id'] == seq_map[i - 2]['seq_id'] \ and seq_map[i]['seq_id'] != seq_map[i - 1]['seq_id']: seq_map[i]['speaker_str'] = "" seq_map[i]['speech_act'] = "" seq_map[i]['paragraph'] = True return seq_map def report_seq(self, seq_map): """Convert sequence of speeches to a tokens.""" sents = [] for i in range(0, len(seq_map)): if seq_map[i]['paragraph']: # text += "\n " quote_start = '"' else: quote_start = "" if i > len(seq_map) - 2 or seq_map[i + 1]['paragraph']: quote_end = '"' else: quote_end = " " if len(seq_map[i]['speech_act']) > 0: speech_act = seq_map[i]['speech_act'] + "," else: speech_act = seq_map[i]['speech_act'] tokens = [utils.START_TOKEN] tokens.append(seq_map[i]['speaker_str']) tokens.append(speech_act) tokens.append(quote_start) tokens.extend(seq_map[i]['speech'][1:-1]) tokens.append(quote_end) tokens.append(utils.END_TOKEN) sents.append(tokens) return sents def make_dialogue(self, seeds): """Returns a list of sentences, each being a list of tokens.""" acts = self.make_speech_bits(seeds) seq_map = self.simplify(acts) sents = self.report_seq(seq_map) return(sents) def dev(): <|fim_middle|> <|fim▁end|>
import knowledge.names as names mcW = mc.MarkovChain() nm = names.NameMaker() speakers = [nm.random_person() for i in range(1, 4)] dm = dialogue_maker([n['name'] for n in speakers], [n['pronoun'] for n in speakers], mcW) dlg = dm.make_dialogue(["dog", "run", "spot"]) print(dlg)
<|file_name|>dialogue.py<|end_file_name|><|fim▁begin|>import numpy as np from numpy import cumsum, sum, searchsorted from numpy.random import rand import math import utils import core.sentence as sentence import core.markovchain as mc import logging logger = logging.getLogger(__name__) # Dialogue making class. Need to review where to return a string, where to return a list of tokens, etc. # setters: list of speakers, pronouns, priors etc. # random transitions # Internal: build list of structures: # e.g.{:speaker_name "Alice", :speaker_pronoun "she", :speaker_str "she", :speech_verb "said", :position "end"} # Then end with fn that maps that out to a suitable string # e.g. "<SPEECH>, she said." # External bit then replaces <SPEECH> with a markov-chain-generated sentence (or several). class dialogue_maker(object): """Class to handle creating dialogue based on a list of speakers and a sentence generator.""" def __init__(self, names, pronouns, mc): self.speakers = [{"name": n, "pronoun": p} for n, p in list(zip(names, pronouns))] self._transitions = self.make_transition_probs() self._speech_acts = ["said", "whispered", "shouted", "cried"] self._acts_transitions = [25, 2, 2, 2] self.mc = mc # self.seeds = seeds self.target_len = np.random.randint(5, 50, size=len(names)) # rough words per sentence def make_transition_probs(self): """Make transition matrix between speakers, with random symmetric biases added in""" n = len(self.speakers) # TODO why this line ??? transitions = np.random.randint(5, size=(n, n)) + 1 transitions += transitions.transpose() for i in range(0, math.floor(n / 2)): s1 = np.random.randint(n) s2 = np.random.randint(n) transitions[s1][s2] += 10 transitions[s2][s1] += 8 return(transitions) def after(self, speaker_id): """Pick next person to speak""" row = self._transitions[speaker_id] sucessor = searchsorted(cumsum(row), rand() * sum(row)) return sucessor def speaker_sequence(self, speaker_id, n): """Random walk through transitions matrix to produce a sequence of speaker ids""" seq = [] for i in range(n): seq.append(speaker_id) speaker_id = self.after(speaker_id) return seq def speech_sequence(self, n): speech_acts_seq = [] next_speech_id = 0 for i in range(n): next_speech_id = searchsorted(cumsum(self._acts_transitions), rand() * sum(self._acts_transitions)) speech_acts_seq.append(self._speech_acts[next_speech_id]) return speech_acts_seq def seq_to_names(self, sequence): return([self.speakers[id] for id in sequence]) def make_speech_bits(self, seeds): n = len(seeds) speaker_id = self.speaker_sequence(0, n) speech_acts_seq = self.speech_sequence(n) bits = [] ss = sentence.SentenceMaker(self.mc) for i in range(n): sent_toks = ss.generate_sentence_tokens([seeds[i]], self.target_len[speaker_id[i]]) sent_toks = ss.polish_sentence(sent_toks) bits.append({'speaker_name': self.speakers[speaker_id[i]]["name"], 'speech_act': speech_acts_seq[speaker_id[i]], 'seq_id': speaker_id[i], 'speech': sent_toks, 'paragraph': True}) return(bits) def simplify(self, seq_map): "Take a sequence of speech parts and make more natural by removing name reptition etc." for i in range(0, len(seq_map)): seq_map[i]['speaker_str'] = seq_map[i]['speaker_name'] # default # Same speaker contiues: if i > 0 and seq_map[i]['seq_id'] == seq_map[i - 1]['seq_id']: <|fim_middle|> else: if i > 1 and seq_map[i]['seq_id'] == seq_map[i - 2]['seq_id'] \ and seq_map[i]['seq_id'] != seq_map[i - 1]['seq_id']: seq_map[i]['speaker_str'] = "" seq_map[i]['speech_act'] = "" seq_map[i]['paragraph'] = True return seq_map def report_seq(self, seq_map): """Convert sequence of speeches to a tokens.""" sents = [] for i in range(0, len(seq_map)): if seq_map[i]['paragraph']: # text += "\n " quote_start = '"' else: quote_start = "" if i > len(seq_map) - 2 or seq_map[i + 1]['paragraph']: quote_end = '"' else: quote_end = " " if len(seq_map[i]['speech_act']) > 0: speech_act = seq_map[i]['speech_act'] + "," else: speech_act = seq_map[i]['speech_act'] tokens = [utils.START_TOKEN] tokens.append(seq_map[i]['speaker_str']) tokens.append(speech_act) tokens.append(quote_start) tokens.extend(seq_map[i]['speech'][1:-1]) tokens.append(quote_end) tokens.append(utils.END_TOKEN) sents.append(tokens) return sents def make_dialogue(self, seeds): """Returns a list of sentences, each being a list of tokens.""" acts = self.make_speech_bits(seeds) seq_map = self.simplify(acts) sents = self.report_seq(seq_map) return(sents) def dev(): import knowledge.names as names mcW = mc.MarkovChain() nm = names.NameMaker() speakers = [nm.random_person() for i in range(1, 4)] dm = dialogue_maker([n['name'] for n in speakers], [n['pronoun'] for n in speakers], mcW) dlg = dm.make_dialogue(["dog", "run", "spot"]) print(dlg) <|fim▁end|>
seq_map[i]['speaker_str'] = "" seq_map[i]['speech_act'] = "" seq_map[i]['paragraph'] = False
<|file_name|>dialogue.py<|end_file_name|><|fim▁begin|>import numpy as np from numpy import cumsum, sum, searchsorted from numpy.random import rand import math import utils import core.sentence as sentence import core.markovchain as mc import logging logger = logging.getLogger(__name__) # Dialogue making class. Need to review where to return a string, where to return a list of tokens, etc. # setters: list of speakers, pronouns, priors etc. # random transitions # Internal: build list of structures: # e.g.{:speaker_name "Alice", :speaker_pronoun "she", :speaker_str "she", :speech_verb "said", :position "end"} # Then end with fn that maps that out to a suitable string # e.g. "<SPEECH>, she said." # External bit then replaces <SPEECH> with a markov-chain-generated sentence (or several). class dialogue_maker(object): """Class to handle creating dialogue based on a list of speakers and a sentence generator.""" def __init__(self, names, pronouns, mc): self.speakers = [{"name": n, "pronoun": p} for n, p in list(zip(names, pronouns))] self._transitions = self.make_transition_probs() self._speech_acts = ["said", "whispered", "shouted", "cried"] self._acts_transitions = [25, 2, 2, 2] self.mc = mc # self.seeds = seeds self.target_len = np.random.randint(5, 50, size=len(names)) # rough words per sentence def make_transition_probs(self): """Make transition matrix between speakers, with random symmetric biases added in""" n = len(self.speakers) # TODO why this line ??? transitions = np.random.randint(5, size=(n, n)) + 1 transitions += transitions.transpose() for i in range(0, math.floor(n / 2)): s1 = np.random.randint(n) s2 = np.random.randint(n) transitions[s1][s2] += 10 transitions[s2][s1] += 8 return(transitions) def after(self, speaker_id): """Pick next person to speak""" row = self._transitions[speaker_id] sucessor = searchsorted(cumsum(row), rand() * sum(row)) return sucessor def speaker_sequence(self, speaker_id, n): """Random walk through transitions matrix to produce a sequence of speaker ids""" seq = [] for i in range(n): seq.append(speaker_id) speaker_id = self.after(speaker_id) return seq def speech_sequence(self, n): speech_acts_seq = [] next_speech_id = 0 for i in range(n): next_speech_id = searchsorted(cumsum(self._acts_transitions), rand() * sum(self._acts_transitions)) speech_acts_seq.append(self._speech_acts[next_speech_id]) return speech_acts_seq def seq_to_names(self, sequence): return([self.speakers[id] for id in sequence]) def make_speech_bits(self, seeds): n = len(seeds) speaker_id = self.speaker_sequence(0, n) speech_acts_seq = self.speech_sequence(n) bits = [] ss = sentence.SentenceMaker(self.mc) for i in range(n): sent_toks = ss.generate_sentence_tokens([seeds[i]], self.target_len[speaker_id[i]]) sent_toks = ss.polish_sentence(sent_toks) bits.append({'speaker_name': self.speakers[speaker_id[i]]["name"], 'speech_act': speech_acts_seq[speaker_id[i]], 'seq_id': speaker_id[i], 'speech': sent_toks, 'paragraph': True}) return(bits) def simplify(self, seq_map): "Take a sequence of speech parts and make more natural by removing name reptition etc." for i in range(0, len(seq_map)): seq_map[i]['speaker_str'] = seq_map[i]['speaker_name'] # default # Same speaker contiues: if i > 0 and seq_map[i]['seq_id'] == seq_map[i - 1]['seq_id']: seq_map[i]['speaker_str'] = "" seq_map[i]['speech_act'] = "" seq_map[i]['paragraph'] = False else: <|fim_middle|> return seq_map def report_seq(self, seq_map): """Convert sequence of speeches to a tokens.""" sents = [] for i in range(0, len(seq_map)): if seq_map[i]['paragraph']: # text += "\n " quote_start = '"' else: quote_start = "" if i > len(seq_map) - 2 or seq_map[i + 1]['paragraph']: quote_end = '"' else: quote_end = " " if len(seq_map[i]['speech_act']) > 0: speech_act = seq_map[i]['speech_act'] + "," else: speech_act = seq_map[i]['speech_act'] tokens = [utils.START_TOKEN] tokens.append(seq_map[i]['speaker_str']) tokens.append(speech_act) tokens.append(quote_start) tokens.extend(seq_map[i]['speech'][1:-1]) tokens.append(quote_end) tokens.append(utils.END_TOKEN) sents.append(tokens) return sents def make_dialogue(self, seeds): """Returns a list of sentences, each being a list of tokens.""" acts = self.make_speech_bits(seeds) seq_map = self.simplify(acts) sents = self.report_seq(seq_map) return(sents) def dev(): import knowledge.names as names mcW = mc.MarkovChain() nm = names.NameMaker() speakers = [nm.random_person() for i in range(1, 4)] dm = dialogue_maker([n['name'] for n in speakers], [n['pronoun'] for n in speakers], mcW) dlg = dm.make_dialogue(["dog", "run", "spot"]) print(dlg) <|fim▁end|>
if i > 1 and seq_map[i]['seq_id'] == seq_map[i - 2]['seq_id'] \ and seq_map[i]['seq_id'] != seq_map[i - 1]['seq_id']: seq_map[i]['speaker_str'] = "" seq_map[i]['speech_act'] = "" seq_map[i]['paragraph'] = True