import os
import stat
import time


def updateModificationTime(path):
    accessTime = os.stat(path)[stat.ST_ATIME]
    modificationTime = time.time()
    os.utime(path, (accessTime, modificationTime))

import os
import stat
import time

from PyQt4.QtCore import SIGNAL
from PyQt4.QtGui import QAction, QKeySequence, QMenu, QShortcut
from aqt import mw


def addMenu(name):
    if not hasattr(mw, 'customMenus'):
        mw.customMenus = {}

    if name not in mw.customMenus:
        menu = QMenu('&' + name, mw)
        mw.customMenus[name] = menu
        mw.form.menubar.insertMenu(mw.form.menuTools.menuAction(),
                                   mw.customMenus[name])


def addMenuItem(menuName, text, function, keys=None):
    action = QAction(text, mw)

    if keys:
        action.setShortcut(QKeySequence(keys))

    mw.connect(action, SIGNAL('triggered()'), function)

    if menuName == 'File':
        mw.form.menuCol.addAction(action)
    elif menuName == 'Edit':
        mw.form.menuEdit.addAction(action)
    elif menuName == 'Tools':
        mw.form.menuTools.addAction(action)
    elif menuName == 'Help':
        mw.form.menuHelp.addAction(action)
    else:
        addMenu(menuName)
        mw.customMenus[menuName].addAction(action)


def addShortcut(function, keys):
    shortcut = QShortcut(QKeySequence(keys), mw)
    mw.connect(shortcut, SIGNAL('activated()'), function)


def updateModificationTime(path):
    accessTime = os.stat(path)[stat.ST_ATIME]
    modificationTime = time.time()
    os.utime(path, (accessTime, modificationTime))

Add helper functions for adding menu items & shortcuts
Add helper functions for adding menu items & shortcuts

- import os
+ import os
- import stat
+ import stat
- import time
+ import time
- 
- 
- def updateModificationTime(path):
-     accessTime = os.stat(path)[stat.ST_ATIME]
-     modificationTime = time.time()
-     os.utime(path, (accessTime, modificationTime))
  
+ from PyQt4.QtCore import SIGNAL
+ from PyQt4.QtGui import QAction, QKeySequence, QMenu, QShortcut
+ from aqt import mw
+ 
+ 
+ def addMenu(name):
+     if not hasattr(mw, 'customMenus'):
+         mw.customMenus = {}
+ 
+     if name not in mw.customMenus:
+         menu = QMenu('&' + name, mw)
+         mw.customMenus[name] = menu
+         mw.form.menubar.insertMenu(mw.form.menuTools.menuAction(),
+                                    mw.customMenus[name])
+ 
+ 
+ def addMenuItem(menuName, text, function, keys=None):
+     action = QAction(text, mw)
+ 
+     if keys:
+         action.setShortcut(QKeySequence(keys))
+ 
+     mw.connect(action, SIGNAL('triggered()'), function)
+ 
+     if menuName == 'File':
+         mw.form.menuCol.addAction(action)
+     elif menuName == 'Edit':
+         mw.form.menuEdit.addAction(action)
+     elif menuName == 'Tools':
+         mw.form.menuTools.addAction(action)
+     elif menuName == 'Help':
+         mw.form.menuHelp.addAction(action)
+     else:
+         addMenu(menuName)
+         mw.customMenus[menuName].addAction(action)
+ 
+ 
+ def addShortcut(function, keys):
+     shortcut = QShortcut(QKeySequence(keys), mw)
+     mw.connect(shortcut, SIGNAL('activated()'), function)
+ 
+ 
+ def updateModificationTime(path):
+     accessTime = os.stat(path)[stat.ST_ATIME]
+     modificationTime = time.time()
+     os.utime(path, (accessTime, modificationTime))
+ 
Add helper functions for adding menu items & shortcuts
## Code Before:
import os
import stat
import time


def updateModificationTime(path):
    accessTime = os.stat(path)[stat.ST_ATIME]
    modificationTime = time.time()
    os.utime(path, (accessTime, modificationTime))

## Instruction:
Add helper functions for adding menu items & shortcuts
## Code After:
import os
import stat
import time

from PyQt4.QtCore import SIGNAL
from PyQt4.QtGui import QAction, QKeySequence, QMenu, QShortcut
from aqt import mw


def addMenu(name):
    if not hasattr(mw, 'customMenus'):
        mw.customMenus = {}

    if name not in mw.customMenus:
        menu = QMenu('&' + name, mw)
        mw.customMenus[name] = menu
        mw.form.menubar.insertMenu(mw.form.menuTools.menuAction(),
                                   mw.customMenus[name])


def addMenuItem(menuName, text, function, keys=None):
    action = QAction(text, mw)

    if keys:
        action.setShortcut(QKeySequence(keys))

    mw.connect(action, SIGNAL('triggered()'), function)

    if menuName == 'File':
        mw.form.menuCol.addAction(action)
    elif menuName == 'Edit':
        mw.form.menuEdit.addAction(action)
    elif menuName == 'Tools':
        mw.form.menuTools.addAction(action)
    elif menuName == 'Help':
        mw.form.menuHelp.addAction(action)
    else:
        addMenu(menuName)
        mw.customMenus[menuName].addAction(action)


def addShortcut(function, keys):
    shortcut = QShortcut(QKeySequence(keys), mw)
    mw.connect(shortcut, SIGNAL('activated()'), function)


def updateModificationTime(path):
    accessTime = os.stat(path)[stat.ST_ATIME]
    modificationTime = time.time()
    os.utime(path, (accessTime, modificationTime))
